fix(cli): preserve inline blocks without file or as attributes

This commit is contained in:
2026-07-08 16:49:01 +08:00
parent 6ab6b76978
commit ae3045f96b
+6 -1
View File
@@ -70,6 +70,11 @@ export function extractInlineBlocks(
(_match: string, lang: string, infoString: string, body: string) => { (_match: string, lang: string, infoString: string, body: string) => {
const attrs = parseAttrs(infoString); const attrs = parseAttrs(infoString);
// Only process blocks that have `file` or `as`; leave others untouched
if (!attrs.file && !attrs.as) {
return _match;
}
// Determine filename: explicit `file` or content-hash generated // Determine filename: explicit `file` or content-hash generated
const filename = const filename =
attrs.file || `_inline_${contentHash(body)}.${lang || "txt"}`; attrs.file || `_inline_${contentHash(body)}.${lang || "txt"}`;
@@ -94,7 +99,7 @@ export function extractInlineBlocks(
return `:${attrs.as}[./${filename}]${extraStr}`; return `:${attrs.as}[./${filename}]${extraStr}`;
} }
return ""; // no `as` — strip the block entirely return ""; // has `file` but no `as` — strip the block (body is already injected into index)
}, },
); );
} }