Skip to content

Support fenced code blocks with 4+ backticks#933

Merged
syohex merged 2 commits intojrblevin:masterfrom
systemfreund:fix/support-4plus-backtick-fences
Mar 1, 2026
Merged

Support fenced code blocks with 4+ backticks#933
syohex merged 2 commits intojrblevin:masterfrom
systemfreund:fix/support-4plus-backtick-fences

Conversation

@systemfreund
Copy link
Copy Markdown

Summary

  • GFM fenced code block regexes now match 3+ backticks instead of exactly 3
  • Closing fence dynamically requires at least as many backticks as the opening fence (same approach already used for tilde fences)
  • Headers inside 4+ backtick blocks are no longer treated as outline headings, imenu entries, or font-lock targets

Fixes #932

Previously, GFM fenced code block regexes matched exactly three
backticks, causing blocks with four or more backticks to be
unrecognized.  This meant headers inside such blocks were
incorrectly treated as document structure (outline headings,
imenu entries, font-lock targets).

Apply the same variable-length fence approach already used for
tilde fences: match 3+ backticks in the opening/closing regexes,
and dynamically require the closing fence to have at least as
many backticks as the opening fence.

Fixes: jrblevin#932

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@syohex syohex merged commit e4be4c1 into jrblevin:master Mar 1, 2026
4 checks passed
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.

Headers inside code blocks with 4+ backticks are incorrectly treated as foldable sections

2 participants