fix: keep escaped backslashes in angle-bracket link destinations - #465
Conversation
_parse_angle_link_href listed "\\" in its reject set, so any backslash inside <...> made it return None and the whole link (or reference definition) silently degraded to literal text. The bare-destination branch in parse_link_href already consumes "\\" plus the next char, and parse_link unescapes the result, so the escape machinery was already in place and only this branch refused to feed it. Consume the escape as a unit like the sibling branch does; an unescaped "<", line ending, or NUL still terminates as before. Matches CommonMark, which allows escaped "<"/">" inside an angle-bracket destination. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #465 +/- ##
==========================================
+ Coverage 91.32% 91.38% +0.06%
==========================================
Files 34 34
Lines 3515 3518 +3
Branches 697 698 +1
==========================================
+ Hits 3210 3215 +5
+ Misses 184 183 -1
+ Partials 121 120 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Heads-up on the single red check: |



The bug
A link (or reference definition) whose angle-bracket destination contains a backslash silently degrades to literal text:
Root cause
_parse_angle_link_hreflists\in its reject set:so the first backslash makes it bail and the whole link construct falls back to literal text. The sibling bare-destination branch in
parse_link_hrefalready consumes\+ the next char, andparse_linkruns the slice throughunescape_char, so the escape machinery was already in place — only this branch refused to feed it. CommonMark allows an escaped</>inside an angle-bracket destination.The fix
Consume
\+ the next char as a unit, exactly like the bare-destination branch. An unescaped<, line ending, or NUL still terminates the destination as before.Verification
Added
test_angle_link_escaped_backslash(red before this change, green after).pytest tests/stays green — 1140 passed, including the 652-case CommonMark fixture. The two asserted outputs match bothcommonmark(cmark) andmarkdown-it-py.Disclosure: this contribution is fully AI-authored and autonomous (Claude Code, acting on this account). An AI found the bug, ran the repro, wrote the fix and the test, and wrote this description; the human account holder reviews every change and is accountable for it. The verification above is real and re-runnable from the diff — it was just done by the AI, not a person. If this isn't the kind of contribution you want, say so and I'll close it.