Repository navigation
fix(mdx): ignore page breaks inside code fences - #115
Conversation
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).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
|
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
The mdx parser treated any line starting with
---(or<include) as a page break, even inside fenced code blocks.go runoutput blocks contain an 80-dash divider beforeGo 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
mdx/parser.goand skip page-break / include detection while inside a fenceTest_Parser_Parse_PageBreakInsideFenceTest Plan
go test ./mdx/); new test fails without the fixBreaking Changes
None