Conversation
There was a problem hiding this comment.
Copilot review overview
馃煛 Changes recommended
Two moderate regression-coverage gaps remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes code-span parsing after unclosed link or image labels by making backtick-run lookup independent of parser traversal.
Changes:
- Reworks backtick caching and boundary handling.
- Updates inline state documentation.
- Adds regression fixtures and a changelog entry.
| File | Summary |
|---|---|
tests/鈥媡est_port/鈥媐ixtures/鈥媍ommonmark_extras.md |
Adds regression coverage for issue #438. |
markdown_it/鈥媟ules_inline/鈥媠tate_inline.py |
Documents revised cache semantics. |
markdown_it/鈥媟ules_inline/鈥媌ackticks.py |
Builds a parser-independent backtick-run cache. |
CHANGELOG.md |
Records the fix. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+783
to
+787
| A longer backtick run outside a link label must not close a shorter opener. | ||
| . | ||
| [`](``) | ||
| . | ||
| <p><a href="%60%60">`</a></p> |
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 #438.
An unclosed link or image label runs inline parsing in a lookahead. The old incremental backtick cache could then claim there was no closer for a code span when the line was parsed for real, leaving valid code spans as literal backticks.
Build the last position of each backtick run length once from the whole source, independently of the parser's traversal. As in upstream markdown-it commit 5e9b1cc830, measure complete runs when a lookahead narrows
posMax, so a run crossing the boundary cannot become a false closer. The existing Python code-span whitespace behavior is retained.Regression fixtures cover unclosed link and image labels, a run crossing the link-label boundary, and code-span precedence over links. The changelog records the fix.
Validation on Windows / Python 3.12.2:
python -m pytest tests -q --maxfail=1 --tb=shortpassed: 1036 tests.ruff check,ruff format --check, andmypy markdown_it/rules_inline/backticks.pypassed.The test commands used
PYTHONUTF8=1because the Windows default GBK encoding cannot read the project's CommonMark test data. The repository-root test command also collects benchmark tests that require an optional benchmark plugin; the projecttests/suite is green. CI remains to be verified.Ported with OpenAI Codex assistance from the upstream markdown-it fix.