Shinmera/plump

html-default applies to all elements

Yehouda opened this issue · 1 comments

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></test">" rather than "<test/>". 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/>".

(test tag
  (test-equal "@test()"
              "<test/>")
  (test-equal "@test(a)"
              "<test>a</test>"))

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.