🐛 Preserve whitespace in parsed-literal directives#1176
Open
deepakganesh78 wants to merge 2 commits into
Open
Conversation
Protect line-edge whitespace while Markdown inline markup is parsed, then restore it in the generated text nodes. Add regression coverage for spaces, tabs, trailing whitespace, inline markup, and private-use characters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace private-use sentinels with an opt-in markdown-it newline rule that retains adjacent whitespace without changing delimiter classification. Add regressions for cross-line emphasis, decoded private-use entities, and the full private-use range. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
parsed-literalcontent is processed by MyST's Markdown inline parserParsedLiteral, leaving other directives' inline parsing unchangedImplementation
ParsedLiteralrelies onstate.inline_text(), while markdown-it's standard newline rule consumes line-edge whitespace and converts two trailing spaces into a hard break. MyST now installs an opt-in newline rule that is activated only while parsingParsedLiteral: it emits a soft break without consuming adjacent whitespace. The parser therefore sees the untouched source for delimiter classification, and no sentinel characters or collision-prone substitutions are required.Validation
python -m tox -e py311-sphinx8(1239 passed, 21 skipped)python -m tox -e py311-sphinx9(1243 passed, 17 skipped)python -m tox -e ruff-fmt -- --checkpython -m tox -e ruff-checkpython -m tox -e mypyfoo * \nbar*remains literal text and all U+E000–U+F8FF characters plus decoded/round-trip without collision or exhaustionFixes #1016