Newline before </code></pre>

Michel Fortin michel.fortin at michelf.com
Sun Jul 2 23:05:27 EDT 2006


Le 2 juil. 2006 à 18:32, Jon Noring a écrit :


> Now, I don't know the reason in Perl or PHP markdown for preserving

> CR/LF characters using <pre>, but there must be some reason. I'm

> only trying to give some background information.


The reason PHP Markdown does it is because Markdown does it. I think
two things may have weighted for this behaviour in Markdown:

* It generates undoubtedly prettier code to look at and with HTML
(or XHTML
served as text/html as everyone does) it changes nothing. I
suppose,
until now, no one bothered to check the result with true XHTML
served as
XML.

* It may have been found safer regarding the _HashHTMLBlocks function
which handle code blocks whether they are part of the input or were
generated by Markdown. While in its current form _HashHTMLBlocks
can
handle `</pre></code>` just fine without the preceding newline,
it may
not have always be the case.

In any case, neither of these reasons holds if the end result in the
browser is not right. So I agree the newline should be removed to
solve the XHTML problem. I'll probably do that in the next version of
PHP Markdown. I may do a new version on my own soon, as the bug list
keeps growing.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/


More information about the Markdown-Discuss mailing list