| > where in the HTML spec does it say that the interior of pre is parsed differently? I was wrong about that. I had a vague memory of putting HTML inside a PRE tag once and having it come out as if it were escaped, but apparently I hallucinated that. > A major example is that the Vim editor uses pre for formatting syntax colored code to HTML (when you do that with :TOhtml). OK, I stand corrected on that too. > If we are parsing HTML (to Lisp objects or whatever), we should preserve the exact whitespace. The reverse generation should regurgitate the original whitespace.
> If we take the license to eliminate newlines, then we ruin pre. The fix is simply not to do that. Right. Actually, I just realized that I mis-read the example. I saw <br /> and thought it was </br>. (Maybe the OP edited it?) In any case, the example now reads: <pre>
<span>one
</span>
<br>
<span>two</span>
<br />
</pre>
And you can render that in sexpr syntax as: (:pre "
" (:span "one
") "
" (:br) "
" (:span "two") "
" (:br) "
")
This is a particularly bad example to demonstrate here because the whitespace in the code plays badly with the whitespace in the HN markup. But I tried running this code and it does work. Here is the output copied-and-pasted verbatim from my listener: <pre>
<span>one
</span>
<br />
<span>two</span>
<br />
</pre>
Note that both BR tags are rendered as <br />. |
This is why you would need separate tags to emit them properly with an S-expr syntax (tag), (tag/), and (tag)(/tag) in my example.