phtml and deprecated HTML

Andrew Philpot <[email protected]> Wed, 2 Apr 2003 13:13:28 -0800
Newsgroups gmane.lisp.open-source.franz
Message-ID <[email protected]>
I notice that PHTML tries to be smart about closing and restarting
low-level character formatting tags, etc., when other kinds of tags
are embedded inside them:

NET.HTML.PARSER(351): (pprint (parse-html "<B><FONT NAME=ARIAL><P>Hello</P>Goodbye</FONT></B>"))

((:B ((:FONT :NAME "ARIAL")))
 (:P ((:FONT :NAME "ARIAL") (:B "Hello")))
 (:B ((:FONT :NAME "ARIAL") "Goodbye")))

In most instances this is be a good thing.  However, I offer the
following two observations:

1. It seems odd for the parser to generate a form of LHTML that can't
   be fed directly back into the html generator cleanly:

NET.HTML.PARSER(359): (net.html.generator::html-stream
		       *standard-output*
		       ((:B ((:FONT :NAME "ARIAL")))
			(:P ((:FONT :NAME "ARIAL") (:B "Hello")))
			(:B ((:FONT :NAME "ARIAL") "Goodbye"))))
Warning: arg list (((:FONT :NAME "ARIAL"))) isn't even
<b ((FONT NAME ARIAL))="NIL"><p><font NAME="ARIAL"><b>Hello</b></font></p><b><font NAME="ARIAL">Goodbye</font></b></b>

After all, you could have generated the original:

(net.html.generator::html-stream
 *standard-output*
 (:B ((:FONT :NAME "ARIAL") (:P "Hello") "Goodbye")))

<b><font NAME="ARIAL"><p>Hello</p>Goodbye</font></b>

2. I was looking for a way to turn this behavior off, particularly for
   those cases e.g., extraction of data from HTML pages, where
   fidelity to the precise original structure might be more valuable
   than adherence to strict W3C guidelines...  The best I could come
   up with was to bind net.html.parser::*in-line* and
   net.html.parser::*ch-format* to NIL around the parse.  That works
   at least in the cases I tested but seems awfully imprecise and
   prone to unanticipated effects...

I just downloaded the latest phtml, so this is not a patch issue
AFAIK.

Andrew