Last modified: 2014-07-25 16:29:17 UTC
In HTML, pre can contain nested elements and formatting. This is also true in VE. In wikitext, formatting in pre is only supported when using the indent-pre serialization. The downside of the indent serialization is that 1) HTML tags in text need to be entity-escaped (ugly wikitext), and 2) trailing newlines require workarounds with <nowiki/> or <br>. The best serialization strategy thus depends on the content of the pre. We should serialize modified or new pre elements to 1) html-syntax pre if the text content contains html tags but no elements, and 2) indent pre syntax if the content contains elements. Trailing newlines in HTML "<pre>foo\n\n</pre>" need to be protected with a trailing <nowiki/> as in " foo\n \n <nowiki/>".
Another reason to pick html syntax pres it if the text-only content contains wikitext syntax that would otherwise be <nowiki>-escaped.
We should also strip a trailing <nowiki/> token when handling an indent pre in the pre handler, so that it does not show up in HTML.
We currently lose trailing newlines. Test case below to add to parser tests. [subbu@earth tests] echo "<pre>foo\n\n\n</pre>" |node parse --html2wt foo [subbu@earth tests]
Also: echo -e '<pre>foo\n\n\n\n\n\n</pre>' | node parse --wt2wt
(In reply to comment #4) > Also: echo -e '<pre>foo\n\n\n\n\n\n</pre>' | node parse --wt2wt This is actually bug 50906.
This is part of the set of bugs for improving serialization support for arbitrary HTML. We should get to this, but after we get through the current round of bugs for rendering. Hence marking this as enhancement.