Shinmera / plump

Practically Lenient and Unimpressive Markup Parser for Common Lisp
https://shinmera.github.io/plump
zlib License
120 stars 21 forks source link

html-default applies to all elements #37

Closed Yehouda closed 2 years ago

Yehouda commented 3 years ago

In special-tags.lisp, there is this form:

(define-wildcard-dispatcher html-default *tag-dispatchers* *html-tags*)

As far as I can tell, that means html-default is applicable to all elements, because the method serialize-object for element (inside the defegenric in dom.lisp) check tag-descriptors (using plump-parser:do-tag-printers). Is that intentional?

It means that

(plump:serialize (plump-parser:parse "<test/>") t)

returns "\</test">" rather than "\". The longer string is the result of the printer of html-default. The shorter one is what the serialize-object method for element would output if it didn't find a tag-printer.

I encountered that because in the system scriba that uses plump, there is a test that fails in https://github.com/CommonDoc/scriba/blob/master/t/plump.lisp that uses plump:serialize on the result of its own parser which is the same as the result of plump-parser:parse above. and expects to get "\".

(test tag
  (test-equal "@test()"
              "<test/>")
  (test-equal "@test(a)"
              "<test>a</test>"))
Shinmera commented 3 years ago

You are meant to bind *tag-dispatchers* to the format you require, using either *html-tags* or *xml-tags*. The default is a mix between the two. If you want XML-style closing tags like <test/> you need to bind the tags appropriately.