[cl-who-devel] Re: Parsing html again

Victor Kryukov victor.kryukov at gmail.com
Wed Feb 27 18:28:19 UTC 2008


"Andrei Stebakov" <lispercat at gmail.com> writes:

> When we generate the JavaScript <script> with cl-who we need to put the empty
> string at the end of the command to have the closing </script> tag like so:
> (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil)
>           (:html
>            (:head (:title "Temporary page")
>                   (:script :language "JavaScript" :src "/test/scripts.js"
> :type "text/javascript" ""))))
> It will generate:
> <html><head><title>Temporary page</title><script language='JavaScript' src='/
> test/scripts.js' type='text/javascript'></script></head></html>

That strange. On my system, both for SBCL and CLisp,

WHO> (with-html-output-to-string (*standard-output* nil :prologue nil :indent nil)
          (:html
           (:head (:title "Temporary page")
                  (:script :language "JavaScript" :src "/test/scripts.js"
:type "text/javascript"))))
"<html><head><title>Temporary page</title><script language='JavaScript' src='/test/scripts.js' type='text/javascript'></script></head></html>"

If you insist on using non-documented features, like tree-to-string, read
the sources (although the following two variables are documented in
the docs[1]).

WHO> (documentation '*html-empty-tags* 'variable)
"The list of HTML tags that should be output as empty tags.
See *HTML-EMPTY-TAG-AWARE-P*."
WHO> (documentation '*html-empty-tag-aware-p* 'variable)
"Set this to NIL to if you want to use CL-WHO as a strict XML
generator.  Otherwise, CL-WHO will only write empty tags listed
in *HTML-EMPTY-TAGS* as <tag/> (XHTML mode) or <tag> (SGML
mode).  For all other tags, it will always generate
<tag></tag>."
WHO> (member :script *html-empty-tags*)
NIL

[1] http://www.weitz.de/cl-who/#*html-empty-tag-aware-p*

Regards,
Victor.

-- 
My blog: http://macrodefinition.blogspot.com




More information about the Cl-who-devel mailing list