Skip to content

Conversation

@joshdoman
Copy link
Contributor

@joshdoman joshdoman commented Aug 20, 2025

Currently, the parser fails to detect inline code that has multiple consecutive inner backticks (ex: multiple ``inner`` backticks). This was an oversight on my part in PR #19 , as I failed to consider this edge case.

The solution is fairly simple. Instead of preventing any occurrence of the starting backtick sequence inside the code span, we match until we find the proper terminating sequence, one that matches the opener exactly without preceding or subsequent backticks.

Old regex: (?<!`)(`+)(?!`)((?:(?!\1).)+?)(\1)(?!`)

New regex: (?<!`)(`+)(?!`)(.*?)(?=(?<!`)\1(?!`))(\1)

Before:

Screenshot 2025-08-20 at 11 39 08 AM

After:

Screenshot 2025-08-20 at 11 38 56 AM

Summary by cubic

Fix inline code parsing when the content includes consecutive inner backticks (e.g., code with ``inner`` backticks). The parser now finds the correct closing sequence that matches the opener, so code spans render correctly.

  • Bug Fixes
    • Updated regex to match until a non-adjacent closing sequence identical to the opener.
    • Added a test for a single-backtick span containing multi-backtick content.

@panphora
Copy link
Owner

This is fixed

@panphora panphora closed this Aug 21, 2025
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