problem with rendering optionally closed tags
Closed this issue · 1 comments
Tags which have optional closing tags have an edge case that I can't seem to handle.
The only way I've found to output the closing tags for tags where it is optional, such as <P>
, is to set *HTML-STYLE*
to :TREE
.
What I would like to do is always include closing tags, while also not printing pretty.
The reason why is because when printing pretty, lines wrap unexpectedly for <pre><code>
blocks, when I'm trying to illustrate a code snippet verbatim at 80 characters per line.
For example (with-html (:p "hello") (:span "world"))
should be treated as 2 elements at the same hierarchical level, but without *HTML-STYLE*
set to :TREE
, <span>
becomes a child of <p>
.
Example output that I get:
(let ((spinneret:*html-style* :tree)
(*print-pretty* nil))
(spinneret:with-html (:p "hello") (:span "world")))
#|
<p>hello<span>world</span>
|#
(let ((spinneret:*html-style* :tree)
(*print-pretty* t))
(spinneret:with-html (:p "hello") (:span "world")))
#|
<p>
hello
</p>
<span>
world
</span>
|#
To recap, I need a way to get the result of the second example above, but not pretty printed. Instead, this:
<p>hello</p><span>world</span>
Now that I think about it, pretty printing and tree-style printing should be orthogonal. I've updated the code so that binding *html-style*
to :tree
and *print-pretty*
to nil will do what you expected.