Skip to content

fix(mdx): ignore page breaks inside code fences - #115

Merged
corylanou merged 4 commits into
mainfrom
fix/mdx-fenced-page-break
Sep 30, 2026
Merged

corylanou merged 4 commits into
mainfrom
fix/mdx-fenced-page-break

Conversation

@corylanou

Copy link
Copy Markdown
Member

Summary

The mdx parser treated any line starting with --- (or <include) as a page break, even inside fenced code blocks. go run output blocks contain an 80-dash divider before Go Version, so the fence got split across two pages: the first half rendered a stray "`shell paragraph and the second half's closing fence opened a new code block that swallowed the next heading. This is visible on https://hypemd.dev/docs/quickstart/.

Related Issue

Reported by a user against https://hypemd.dev/docs/quickstart/ (no GitHub issue).

Changes

  • Track ``` / ~~~ fence state in mdx/parser.go and skip page-break / include detection while inside a fence
  • Add Test_Parser_Parse_PageBreakInsideFence

Test Plan

  • Tests pass (go test ./mdx/); new test fails without the fix
  • Manually tested with hype documents: rebuilt hypemd.dev with the patched binary, quickstart headings render correctly and only that page's output changes
  • Documentation updated (if applicable)

Breaking Changes

None

Lines starting with --- or <include inside fenced code blocks were
treated as page breaks, splitting the fence and swallowing following
headings into a stray code block (e.g. go run output dividers on the
quickstart doc).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T19:11:30.634076Z e14842b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e14842be36

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread mdx/parser.go Outdated
@corylanou

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Detect fenced code by parsing the document with blackfriday instead of
a hand-rolled fence scanner, so page breaks match how the renderer
reads fences: exact closing markers only, no fences inside raw HTML
blocks, and unterminated openers are not fences.
@corylanou

corylanou commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

Addressed additional review feedback in c392121: fenced-line detection now parses the whole document with blackfriday and only skips break lines that land inside a fenced CodeBlock, so it matches the renderer exactly. Backtick lines inside raw HTML blocks like

 no longer suppress real page breaks, and closing fences must be the exact opening marker (longer runs or trailing spaces don't close). Tests added for both: Test_Parser_Parse_FenceInsideHTMLBlock and Test_Parser_Parse_FenceCloseMustMatchExactly.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@corylanou
corylanou merged commit c45acf8 into main Sep 30, 2026
3 checks passed
@corylanou
corylanou deleted the fix/mdx-fenced-page-break branch September 30, 2026 19:44
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.

1 participant