Repository navigation
Conversation
A backslash before a space is a literal backslash (CommonMark 6.1), but the escape rule consumed the space with it. For 'a\ \nb' the newline rule then saw only one trailing space and emitted a softbreak instead of a hard break. Port the backslash-space branch from upstream markdown-it (56c2404e6d, #1185): emit the backslash and leave the space in the text.
This branch has not been deployed
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 literal backslash before two trailing spaces produces a soft break instead of a hard line break:
A backslash before a space is literal (CommonMark §6.1), so the two trailing spaces should still form a hard break (§6.7). The
escaperule handled backslash-space in its generic branch, emittingtext_specialwith content"\ "and consuming the space. Thenewlinerule then only saw one trailing space instate.pending.This ports the upstream fix from markdown-it (markdown-it/markdown-it@56c2404e6d, #1185). A separate branch for
ch1 == " "emits the backslash astext_special(markup\, infoescape) and leaves the space unconsumed, as in upstreamescape.mjs.The same change was proposed in #417, which its author closed during a cleanup of their older PRs without a review. This PR picks it up again.
Tests:
test_backslash_before_spaceintests/test_port/test_misc.py(hard break, mid-line, single-space soft break). 2 of the 3 cases fail without the changepytest tests: 1193 passeda,\, space, newline, tab,*,`,[, plus hand-written cases (commonmark and default presets). Every backslash/space/newline case now matches