Loading xhtmlambda-pkg.lisp +1 −0 Changes for xhtmlambda-pkg.lisp: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ Yet another HTML/XHTML/XML producing (and parsing) library.") (:export "HTML-SEXP-SYNTAX" "*DEFAULT-HTML-SEXP-SYNTAX*" "*HTML5-NO-SELF-CLOSING-TAG*" ) ) Loading xhtmlambda.lisp +20 −7 Changes for xhtmlambda.lisp: 20 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -14,6 +14,15 @@ (defparameter *downcase-names* t) ;;; http://stackoverflow.com/questions/3558119/are-non-void-self-closing-tags-valid-in-html5 ;;; For backwards compatibility we set it to T, but we can change it if we need ;;; HTML5 style closing tags (defparameter *html5-no-self-closing-tag* 'nil) ;;; https://www.w3.org/TR/html5/syntax.html#void-elements ;;; Void elements only have a start tag; end tags must not be specified for void elements. (defvar *html5-void-elements* '(area base br col embed hr img input keygen link meta param source track wbr)) ;;;;=========================================================================== ;;;; Main definitions. Loading Loading @@ -958,7 +967,8 @@ See Also: (let ((tag (string-downcase (element-tag xhtml-element))) (attrs (element-attributes xhtml-element)) (content (element-content xhtml-element)) ) (html5-void-tag (member (element-tag xhtml-element) *html5-void-elements*))) ;; (cerror "examining tag closing" "data ~a ~a" s xhtml-element) (pprint-logical-block (s content) (pprint-logical-block (s content) ;; (write-string "<" s) Loading @@ -967,18 +977,21 @@ See Also: ;; (format s "<~A~@<~{~^ ~A=\"~S\"~^~_~}~:>" tag attrs) (format s "<~A~@<~{~^ ~A=\"~A\"~^~_~}~:>" tag attrs) (when content (when (or content *html5-no-self-closing-tag*) (write-char #\> s) ;; (pprint-indent :block 4 s) (pprint-newline :mandatory s) (when content (pprint-newline :mandatory s)) (format s "~{~4,0:T~:W~_~}" content) ;; (format s "~{~:W~_~}" content) ;; (pprint-indent :block -4 s) )) (if content (format s "~0I</~A>" tag) ;; (format s "</~A>" tag) (write-string " />" s)) (cond (content (format s "~0I</~A>" tag)) ((and (null content) *html5-no-self-closing-tag*) (unless html5-void-tag ;we don't close html5 void elements (format s "</~A>" tag))) (T (write-string " />" s))) ))) Loading Loading
xhtmlambda-pkg.lisp +1 −0 Changes for xhtmlambda-pkg.lisp: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ Yet another HTML/XHTML/XML producing (and parsing) library.") (:export "HTML-SEXP-SYNTAX" "*DEFAULT-HTML-SEXP-SYNTAX*" "*HTML5-NO-SELF-CLOSING-TAG*" ) ) Loading
xhtmlambda.lisp +20 −7 Changes for xhtmlambda.lisp: 20 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -14,6 +14,15 @@ (defparameter *downcase-names* t) ;;; http://stackoverflow.com/questions/3558119/are-non-void-self-closing-tags-valid-in-html5 ;;; For backwards compatibility we set it to T, but we can change it if we need ;;; HTML5 style closing tags (defparameter *html5-no-self-closing-tag* 'nil) ;;; https://www.w3.org/TR/html5/syntax.html#void-elements ;;; Void elements only have a start tag; end tags must not be specified for void elements. (defvar *html5-void-elements* '(area base br col embed hr img input keygen link meta param source track wbr)) ;;;;=========================================================================== ;;;; Main definitions. Loading Loading @@ -958,7 +967,8 @@ See Also: (let ((tag (string-downcase (element-tag xhtml-element))) (attrs (element-attributes xhtml-element)) (content (element-content xhtml-element)) ) (html5-void-tag (member (element-tag xhtml-element) *html5-void-elements*))) ;; (cerror "examining tag closing" "data ~a ~a" s xhtml-element) (pprint-logical-block (s content) (pprint-logical-block (s content) ;; (write-string "<" s) Loading @@ -967,18 +977,21 @@ See Also: ;; (format s "<~A~@<~{~^ ~A=\"~S\"~^~_~}~:>" tag attrs) (format s "<~A~@<~{~^ ~A=\"~A\"~^~_~}~:>" tag attrs) (when content (when (or content *html5-no-self-closing-tag*) (write-char #\> s) ;; (pprint-indent :block 4 s) (pprint-newline :mandatory s) (when content (pprint-newline :mandatory s)) (format s "~{~4,0:T~:W~_~}" content) ;; (format s "~{~:W~_~}" content) ;; (pprint-indent :block -4 s) )) (if content (format s "~0I</~A>" tag) ;; (format s "</~A>" tag) (write-string " />" s)) (cond (content (format s "~0I</~A>" tag)) ((and (null content) *html5-no-self-closing-tag*) (unless html5-void-tag ;we don't close html5 void elements (format s "</~A>" tag))) (T (write-string " />" s))) ))) Loading