Repository navigation
Conversation
Leading spaces or tabs of paragraph continuation lines are not part of the paragraph's raw content (CommonMark 4.8), but the backticks rule only turned the line ending into a space, so ``a\n b`` gave <code>a b</code> instead of <code>a b</code> (commonmark.js). Fixes executablebooks#475
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.
Fixes #475.
Leading spaces or tabs on paragraph continuation lines are not part of the paragraph's raw content (CommonMark 4.8, example 223). The newline rule already skips them for normal text, but the backticks rule takes the source as is and only turns
\ninto a space, so the indent ends up inside<code>:The fix replaces
\nplus any following spaces/tabs with one space. Trailing spaces before the line ending are kept, as commonmark.js does (`a \n b`→<code>a b</code>).I found this by running markdown-it-py and commonmark.js 0.31.2 on ~30,000 generated inputs. markdown-it 15.0.3 gives the same output as markdown-it-py today.
Tests: 4 new cases in
tests/test_port/fixtures/issue-fixes.md(spaces, tab, list item with extra indent, trailing spaces kept); all 4 fail without the change.pytest tests: 1194 passed; pre-commit (ruff, ruff-format, mypy) clean. On the same 30,000 inputs, 52 more now match commonmark.js and none newly differ.