;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Copyright (C) 1999 Tony Graham
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 2
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 1. Design Considerations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This module declares flow object macros for the elements in the
;; HTML 3.2 DTD. Using these macros makes, or should make, reading
;; and writing stylesheets for HTML output easier.
;;
;; For example, using the flow object macros to generate the HTML:
;;
;;
;;
;; the DSSSL code is:
;;
;; (make p
;; (make a
;; href: "#target"
;; (literal "Link to a target")))
;;
;; Without using the macros, the DSSSL code is:
;;
;; (make element
;; gi: "p"
;; (make element
;; gi: "a"
;; attributes: (list '("href" "#target"))
;; (literal "Link to a target")))
;;
;; As the first example shows, the flow object macro for each HTML
;; element behaves like a DSSSL flow object, and the attributes of the
;; HTML element are declared as characteristics of the HTML "flow
;; object".
;;
;; Since this is still an experimental release, note that:
;;
;; a. All characteristics are optional
;;
;; b. All characteristic values are strings
;;
;; c. No sanity checking is performed on characteristic values, other
;; than checking that values are strings.
;;
;; d. If a characteristic is not declared or its value is not a
;; string, the corresponding attribute will not appear in the HTML
;; output
;;
;; e. Characteristics for all of the attributes of the HTML 3.2
;; elements are declared, no matter how kludgy.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 1.1 Jade command line
;;
;; Since flow object macros are part of Jade's experimental
;; extensions, include the "-2" option in the Jade command line:
;;
;; jade -ccatalog -2 -t sgml -d style.dsl in.sgml > out.html
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 1.2 Referencing the module
;;
;; a. Declare the module as an entity in the internal subset of
;; your stylesheet:
;;
;;
;; ]>
;;
;; b. Wrap your DSSSL code in a element:
;;
;;
;; (element ....)
;;
;;
;; c. Include an element for this module in
;; your stylesheet:
;;
;;
;;
;; The "use" attribute of the element must
;; match the "id" attribute of the
;; element.
;;
;; The "document" attribute of the element
;; must match the name of the entity declared in the internal
;; subset.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 1.3 Reading this module
;;
;; This module includes in its comments the complete declarations from
;; the HTML 3.2 DTD.
;;
;; The comments preceding each flow object macro declaration show both
;; the usage of the flow object macro and the HTML that is produced.
;;
;; The following example show the comment containing the declarations
;; for the element, the usage and example output comment for the
;; br flow object macro, and the declaration for the br flow object
;; macro itself:
;;
;; ;;
;; ;;
;;
;; ;; (make br
;; ;; clear: "CLEAR")
;; ;; =>
;; (declare-flow-object-macro br ((clear #f))
;; (make-empty-element "br" "clear" clear))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 2. External procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define debug
(external-procedure "UNREGISTERED::James Clark//Procedure::debug"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 3. Flow object classes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(declare-flow-object-class element
"UNREGISTERED::James Clark//Flow Object Class::element")
(declare-flow-object-class empty-element
"UNREGISTERED::James Clark//Flow Object Class::empty-element")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 4. Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Version number of this module
(define html-fom-version "0.1")
;; Version of the HTML DTD that we map
(define html-fom-html-version "3.2")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 5. Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (cadr list)
;;
;; Return the car of the cdr of the list, i.e. the second item in the
;; list.
;; (cadr '(a b c d)) => b
(define cadr (lambda (x) (car (cdr x))))
;; (cddr list)
;;
;; Return the cdr of the cdr of the list, i.e. the third and
;; subsequent items in the list.
;; (cddr '(a b c d)) => '(c d)
(define cddr (lambda (x) (cdr (cdr x))))
;; (make-element gi children name1 value1 name2 value2...)
;;
;; Using the "element" flow object class from Jade's SGML backend,
;; make an element with the supplied generic identifier (gi) and
;; children. Any attribute name and value pairs are made into a list
;; of lists suitable for use as the value of the "attributes"
;; characteristic of the "element" flow object. The only error
;; checking on the supplied attribute name and value is that they are
;; both strings: if either is not a string, the name-value pair is
;; ignored.
(define (make-element gi
#!optional (children (empty-sosofo))
#!rest attributes)
(make element
gi: gi
attributes: (let loop ((attr-list attributes)
(result-list '()))
(if (null? attr-list)
result-list
(let ((name (car attr-list))
(value (cadr attr-list)))
(if (and (string? name)
(string? value))
(append
(list (list name value))
(loop (cddr attr-list)
result-list))
(loop (cddr attr-list)
result-list)))))
children))
;; (make-empty-element gi name1 value1 name2 value2...)
;;
;; Using the "empty-element" flow object class from Jade's SGML
;; backend, make an empty element with the supplied generic identifier
;; (gi). Any attribute name and value pairs are made into a list of
;; lists suitable for use as the value of the "attributes"
;; characteristic of the "empty-element" flow object. The only error
;; checking on the supplied attribute name and value is that they are
;; both strings: if either is not a string, the name-value pair is
;; ignored.
(define (make-empty-element gi
#!rest attributes)
(make empty-element
gi: gi
attributes: (let loop ((attr-list attributes)
(result-list '()))
(if (null? attr-list)
result-list
(let ((name (car attr-list))
(value (cadr attr-list)))
(if (and (string? name)
(string? value))
(append
(list (list name value))
(loop (cddr attr-list)
result-list))
(loop (cddr attr-list)
result-list)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 6. Flow object macros for HTML 3.2 elements
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; The complete text of the HTML 3.2 DTD is included in comments so
;; readers can see the derivation of the flow object macros.
;;
;;
;; This is subject to change, pending final approval by the W3C
;; member companies. Changes are limited to bug fixes at this time.
;;
;; HTML 3.2 aims to capture recommended practice as of early '96
;; and as such to be used as a replacement for HTML 2.0 (RFC 1866).
;; Widely deployed rendering attributes are included where they
;; have been shown to be interoperable. SCRIPT and STYLE are
;; included to smooth the introduction of client-side scripts
;; and style sheets. Browsers must avoid showing the contents
;; of these element Otherwise support for them is not required.
;; ID, CLASS and STYLE attributes are not included in this version
;; of HTML.
;;
;; The next version of HTML after Wilbur is code named Cougar and
;; will add support for