Repository navigation
Conversation
Python's \s also matches U+001C-U+001F and U+0085, which are not whitespace in JavaScript or CommonMark. The HTML tag and HTML block regexps and the typographer en dash rules used \s where upstream markdown-it uses the JavaScript \s, so e.g. '<b\x85c="d">' was parsed as an HTML tag and 'a--\x85b' was not turned into an en dash, unlike markdown-it.
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.
Python's regex
\salso matches U+001C–U+001F and U+0085, which are not whitespace in JavaScript or CommonMark. #433 fixed this for trimming, but several regexps ported from markdown-it still use\s:common/html_re.pyand the HTML block start patterns inrules_block/html_block.py, so e.g.<b\x85c="d">was parsed as inline HTML and<div\x1c>opened an HTML block;rules_core/replacements.py, soa--\x85bwas left alone anda\x1c-- bbecame an en dash.They now use a
whitespaceclass ([^\S\x1c-\x1f\x85]) defined inhtml_re.py, matching JavaScript's\s.a <b\x85c="d"> e<p>a <b\x85c="d"> e</p><p>a <b\x85c="d"> e</p><div\x1c>\n\n*x*<p><div\x1c></p>\n<p><em>x</em></p><div\x1c>\n<p><em>x</em></p>a--\x85b(typographer)a–\x85ba--\x85ba\x1c-- b(typographer)a\x1c-- ba\x1c– bNew tests in
tests/test_port/test_whitespace.pycover each of the 5 characters plus controls with a space and a tab; 10 of them fail onmasterand all pass with this change (expected strings checked against markdown-it 15.0.3). The full suite, ruff and mypy pass.Not included: JS
$in multiline mode also matches before U+2028/U+2029, which overlaps #469.I used Claude Code (Opus 5.5) to help investigate and draft this change; I reproduced the bug and checked the fix myself.