Repository navigation
fix(sync): mask fences in mdx-to-markdown inline pass with the shared fence rule - #572
Conversation
… fence rule withCodeProtected masked fenced code with its own regex, which neither skipped a backtick run whose info string contains a backtick nor accepted a closer longer than the opener. convertBlocks uses FenceTracker, so the two passes disagreed on what is code: prose links after such a line could be hidden from the link/image rewrite. Build the fence slots from splitFencedSegments instead and keep the inline-code masking for prose. Closes hivecommons#571 Hive-Run: hivecommons#571 Hive-Plan: reviewer-backlog/correctness Hive-Spec: hivecommons#571 Signed-off-by: Karibhou <Karibhou@users.noreply.github.com>
👷 Deploy request for hivecommons-docs pending review.Visit the deploys page to approve it
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Looks correct to me.
Read withCodeProtected (scripts/mdx-to-markdown.ts:257-271) against splitFencedSegments/FenceTracker (scripts/markdown-fences.ts:28-73) and both call sites (mdx-to-markdown.ts:289-318):
- Segments concatenate back to the original text exactly, so the placeholder swap is lossless; the inline
`…`mask now runs only on prose segments, which is the same per-line behaviour as before. - Keeping the fence's trailing
\noutside the placeholder is what letsIMPORT_RE/EXPORT_RE(^…$withm) still match on the line after a fence — checked that neither anchored pattern can match inside\u0000N\u0000. - The two new tests fail on
main'swithCodeProtected(link left as/install/) and pass at08397a6; the fullmdx-to-markdown*suite passes (51 tests).
The one behaviour change not covered by a test — an unclosed fence now masking to EOF — matches convertBlocks, as the body says, and is the consistent choice.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Read the tree at What I verified
One behaviour change worth a maintainer's eye, already called out in the body: an unclosed fence is now masked to end-of-content, matching I have not approved or merged anything — this is a comment only. Evidence bundle `#57208397a6` sha256:405bf76c7e5ac582044a43897bf7a1c781ea92139fefe855ccf61dcbe404b37b — download from the dashboard or `hivectl review evidence #572`. |
|
Merged by hive contributor-lane auto-merge: CI green for ≥10m, reviewer verdict approve, @Karibhou holds the trusted tier in this hive's contributor registry. |
📌 Fixes
Fixes #571
📝 Summary of Changes
withCodeProtectedinscripts/mdx-to-markdown.tsmasked fenced code with its own regex (/^([ \t]*)({3,}|~{3,})[\s\S]?^\1\2[ \t]$/gm). That regex ignored two rulesFenceTracker` enforces for the block pass since #570:```not`a`fence) is not a fence opener;So the block pass and the inline link/image/brace pass disagreed on what is code, and a prose link after such a line could be masked from the link rewrite if a later fence followed.
withCodeProtectednow builds its fence slots fromsplitFencedSegments(the shared rule) and keeps the inline-code masking for the prose segments only. A fence's trailing newline stays outside the placeholder so^-anchored patterns (IMPORT_RE,EXPORT_RE) still see the next line's start.One consequence: an unclosed fence is now masked to the end of the content, matching how
convertBlocksalready treats it.Changes Made
withCodeProtectedto usesplitFencedSegmentsscripts/mdx-to-markdown.edge-cases.test.ts. They failed before the fix (link left as/install/) and pass after itchangelog.d/fixed-571-mdx-inline-pass-fence-rule.mdChecklist
npx vitest run --coverage(1406 passed, thresholds met),npm run type-check, ESLint, Prettier and markdownlint on the touched files.typoswas not run because it is not installed locally.Security Considerations
Not applicable: build-time sync script only.
— hive: backend=omp model=anthropic/claude-opus-5-5
🐝 Hive Agent:
contributor| SHA:08397a6