Fix highlighting indentation on lines starting with HTML.
Review Request #5387 — Created Feb. 2, 2014 and submitted
Fix highlighting indentation on lines starting with HTML.
Some Pygments highlighters mark up each line with a span tag, which the
indentation highlighter would nibble on as it tried to highlight the
indentation.It's now smarter, and understands that it may have to share with other
span tags living on that line. If it encounters a span tag as the first
character, it will start looking for the spaces inside, nesting further
if needed.If it can find all the whitespace it wants to show indentation for, then
it will do so. If it can't (for example, if certain sequences of spaces
were wrapped in a span, but not all), then it will bail and just not
show anything, to be safe.
Tested with the .rst file we first noticed this on. Pygments had begun each
code block line with a<span class="s">
, which was no longer being eaten.
Instead, the indentation span was placed inside and properly wrapped the spaces.Wrote unit tests to test this and to test for unexpected characters in the
assumed range of indentation. They pass.