Skip to content

fix: preserve code-fence imports when inlining partials - #69

Closed
ilanazholobovsky wants to merge 0 commit into
rachfop:mainfrom
ilanazholobovsky:fix/preserve-code-fence-imports-in-partials
Closed

fix: preserve code-fence imports when inlining partials#69
ilanazholobovsky wants to merge 0 commit into
rachfop:mainfrom
ilanazholobovsky:fix/preserve-code-fence-imports-in-partials

Conversation

@ilanazholobovsky

Copy link
Copy Markdown
Contributor

Follow-up to #55.

When a partial is spliced into a page, its own component imports are removed —
@theme/Tabs and friends mean nothing in plain markdown. That strip is
line-based (/^\s*import\s+.*$/gm), so it also matches any line starting with
import inside a fenced code block:

import Foundation   // deleted from the middle of the sample

The failure is silent: the page still renders, the fence survives, and only the
import lines go missing from the generated markdown.

maskCodeSegments() already exists in this module and is used by
cleanMarkdownContent() and the image rewriter for exactly this reason.
Applying it here protects fenced blocks, tilde fences and inline spans, while
genuine component imports are still stripped since they never sit inside a fence.

Adds tests/test-partial-code-fence-imports.js (registered in test:unit),
which fails before the change — Swift and Kotlin import lines stripped — and
passes after.

@rachfop rachfop closed this Sep 1, 2026
@rachfop
rachfop force-pushed the fix/preserve-code-fence-imports-in-partials branch from de65de1 to 5c793d6 Compare September 1, 2026 04:56
rachfop added a commit that referenced this pull request Sep 1, 2026
Several 0.5.x bugs (#63, #64/#68, #67, #69) shipped because no CI
ever ran against PRs. This runs the full unit + integration suites
on Node 18/20/22 for every pull request and push to main.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@rachfop

rachfop commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Landed on main in 47d10ea (rebased onto #68 so both changes to the test script survived). Apologies for the PR auto-closing — my force-push of the rebase to your fork made head and base point at the same SHA. The fix and your test file are live and credited to you. Thanks for catching the missing maskCodeSegments on the partial-splice path.

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.

2 participants