|
|
|
|
|
by kazinator
3422 days ago
|
|
There are uses for pre with tags embedded. pre provides the simplified line breaking and usually a monospaced font. However, tags are available to do whatever else. A major example is that the Vim editor uses pre for formatting syntax colored code to HTML (when you do that with :TOhtml). The output is a pre block containing various span elements which are styled with CSS. BTW where in the HTML spec does it say that the interior of pre is parsed differently? 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. |
|
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:
And you can render that in sexpr syntax as: 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: Note that both BR tags are rendered as <br />.