Index: who.lisp =================================================================== --- who.lisp (revision 1123) +++ who.lisp (working copy) @@ -58,6 +58,18 @@ (defparameter *empty-tag-end* " />" "End of an empty tag. Default is XML style.") +(defparameter *html-empty-tags* + '(:base :basefont :br :frame :hr :img :input :isindex :link :meta :nextid :range + :spacer :wbr :audioscope :area :param :keygen :col :limittext :spot :tab :over + :right :left :choose :atop :of) + "List of html tags that should close by itself.") + +(defvar *html-empty-tag-aware* T + "Set to NIL to if you want to use cl-who as a strict XML +generator. Otherwise, CL-WHO will only close empty tag defined in +*html-empty-tags* with (XHTML mode) or (SGML mode). For +all other tags, it will always generate .") + (eval-when (:compile-toplevel :load-toplevel :execute) (unless (boundp '+newline+) (defconstant +newline+ (make-string 1 :initial-element #\Newline) @@ -275,8 +287,11 @@ (list +newline+ (n-spaces *indent*))) ;; closing tag (list "")) - ;; no body, so no closing tag - (list *empty-tag-end*))))) + ;; no body, so no closing tag if not defined in *html-empty-tags* + (if (and *html-empty-tag-aware* + (member tag *html-empty-tags*)) + (list *empty-tag-end*) + (list ">" "")))))) (defun apply-to-tree (function test tree) (declare (optimize speed space)) Index: doc/index.html =================================================================== --- doc/index.html (revision 1123) +++ doc/index.html (working copy) @@ -93,6 +93,8 @@
  • show-html-expansion
  • *attribute-quote-char*
  • *prologue* +
  • *html-empty-tag-aware* +
  • *html-empty-tags*
  • *downcase-tags-p*
  • esc
  • fmt @@ -548,6 +550,27 @@


    [Special variable] +
    *html-empty-tag-aware* + +


    +Set to NIL to if you want to use cl-who as a strict XML +generator. Otherwise, CL-WHO will only close empty tag defined in +*html-empty-tags* with <tag/> (XHTML mode) or <tag> (SGML mode). For +all other tags, it will always generate <tag></tag>. The default is T. +
    + +


    [Special variable] +
    *html-empty-tags* + +


    +List of html tags that should close by itself. +The default values are +'(:base :basefont :br :frame :hr :img :input :isindex :link :meta :nextid :range + :spacer :wbr :audioscope :area :param :keygen :col :limittext :spot :tab :over + :right :left :choose :atop :of) +
    + +


    [Special variable]
    *downcase-tags-p*