Skip to content

fix(reflow): support multiple backticks and optimize code span parsing#724

Closed
chandlerc wants to merge 1 commit into
rvben:mainfrom
chandlerc:fixreflow-support-multiple-backticks-and/rzmzkxmyslpz
Closed

fix(reflow): support multiple backticks and optimize code span parsing#724
chandlerc wants to merge 1 commit into
rvben:mainfrom
chandlerc:fixreflow-support-multiple-backticks-and/rzmzkxmyslpz

Conversation

@chandlerc

Copy link
Copy Markdown
Contributor

Update parse_markdown_elements_inner to identify and extract inline code spans using pre-extracted ranges from pulldown-cmark instead of manual character-by-character single-backtick matching.

This fixes the parser to correctly handle code spans delimited by multiple backticks (e.g., double backticks) as atomic code elements conforming to the CommonMark spec. It also eliminates the custom backtick parser loop, ensuring code spans are parsed in linear O(N) time. Stored Element::Code representation is updated to retain its original delimiters, and its Display implementation is updated to render it raw.

Assisted-by: Antigravity with Gemini

Update parse_markdown_elements_inner to identify and extract inline code
spans using pre-extracted ranges from pulldown-cmark instead of manual
character-by-character single-backtick matching.

This fixes the parser to correctly handle code spans delimited by multiple
backticks (e.g., double backticks) as atomic code elements conforming to the
CommonMark spec. It also eliminates the custom backtick parser loop, ensuring
code spans are parsed in linear O(N) time. Stored Element::Code representation
is updated to retain its original delimiters, and its Display implementation
is updated to render it raw.

Assisted-by: Antigravity with Gemini
@rvben

rvben commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Verified and landed on main as 81944c5, cherry-picked with your authorship preserved (the branch had conflicted with the #728 reflow fix that touched the same test module, so I resolved locally rather than round-tripping a rebase).

Verification notes: on main, double backtick spans got split mid-span during reflow and everything after an unclosed backtick was swallowed as unwrappable text; with your change both stay atomic, and a link following a stray backtick wraps correctly. Full dev suite passed locally (11k+ tests).

The finder's rescan-from-start over the code spans was replaced with a monotonic cursor index in a30a4f9, together with the same pattern for the link and emphasis scans. Thanks for the fix!

@rvben rvben closed this Jul 13, 2026
@chandlerc chandlerc deleted the fixreflow-support-multiple-backticks-and/rzmzkxmyslpz branch July 13, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants