Repository navigation
🐛 Parsed literal: a hard break is the line ending, not <br /> - #1247
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Markdown hard break (a backslash at the end of a line) inside a
parsed-literalis rendered as
raw("<br />\n")plusraw("\\\\\n"), the same nodes as in a paragraph.Inside a literal block the line ending is already a line break in every writer,
so the HTML
<pre>draws two: the listing gains an empty line its author never wrote(measured in Chromium on 5.2.0: two lines take 45px, against 30px without the
<br />).The raw LaTeX
\\beside it is replaced by the same line ending.renders as
<pre class="literal-block">alpha <em>em</em><br />\nbeta</pre>.Change
render_hardbreakchecks the flag the parsed-literal inline parse already sets(
_PRESERVE_LINE_EDGE_WHITESPACE, from theparsed-literalline-edge whitespace change),and inside it appends
Text("\n"), the node the preserved newline rule writes for a soft break there.Everywhere else the raw HTML and LaTeX breaks are unchanged.
The two trailing spaces form of a hard break is not affected: inside a parsed literal
the preserved newline rule already keeps them as text, so no hard break arises from them.
Tests
docutil_directives.md:[parsed-literal-hard-break], a break after text and one nested in emphasis,with no
rawnode in the doctree.test_docutils.py: the html5 output of a parsed literal holds no<br,and a paragraph's hard break still renders as
<br />.Both new tests fail before the change and pass after; the rest of the suite passes unchanged.
Not changed
The line after a backslash hard break still loses its leading spaces, as markdown-it's escape rule consumes them;
a parsed literal otherwise keeps every line's indentation. That could be a follow-up.