#5

fix: ignore headings inside fenced code blocks in splitIntoChunks

OpenSufyrwants to merge intofrom

What changed

Fixed splitIntoChunks in @mdxg/parser to properly track code fence state and ignore H1/H2 headings inside fenced code blocks (``` and ~~~).

Why

SPEC Section 6.1 requires: "Headings inside fenced code blocks (``` or ~~~) MUST NOT be treated as page boundaries. The tool MUST track code fence open/close state when scanning for headings."

Previously, splitIntoChunks did not track code fence state, causing headings inside code blocks to be incorrectly treated as page boundaries.

How

Added inCodeFence tracking to splitIntoChunks, matching the existing pattern in extractHeadings.

Before & After

BeforeAfter

Tests

Added 4 test cases:

  • Ignores H1/H2 headings inside fenced code blocks
  • Ignores H1/H2 headings inside tilde code blocks
  • Ignores setext headings inside code blocks
  • Handles multiple code blocks with headings

Activity

2
vercel[bot]6mo ago

@Sufyr is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.