Improve formatting for Markdown.
Review Request #6643 — Created Nov. 25, 2014 and submitted — Latest diff uploaded
We try to keep our Markdown rendered output as close as possible to the source text formatting, but there's only so much that can be done by CSS. This change massively improves the rendering by introducing a set of new Markdown processors that clean up newlines and attributes, giving us the output our users would expect. This primarily does the following: * Keeps the correct number of blank lines between blocks (by default, Python Markdown will just trim them away). * Keeps code blocks (and certain other extension-provided blocks) from having an unnecessary extra blank line after the HTML (interfering with our <pre> formatting). * Allows line breaks in lists. * Wrapped lines of text inside an ordered list item no longer shows the wrapped text at the same indentation level as the item's counter value. It now properly stays within the confines of the list item. To make this happen, we had to use CSS counters and some custom styles (using `display: table` and friends). * Allows ordered lists to start at a particular value. We do this by turning off lazy_ol, which gives us a start= attribute on the list. Then, to get it to play nice with the custom counters mentioned above, we have a Markdown block processor that adds CSS to the <ol> that initializes the counter to the right value. * Adds unit tests to ensure these formatting rules do not break in the future. The result is much nicer formatting for most cases (all cases I've tested).
Tested a variety of Markdown code snippets, with various lengths of
blank lines, and various starting points for lists. Before, we had
rendering issues with all this, but after, it looked as it did in the
source text.Unit tests pass.