mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-28 12:49:48 +08:00
fix(markdown-to-html): preserve inline code inside bold/emphasis
The `extractText()` helper in `preprocessCjkEmphasis()` only handled `text` nodes and nodes with `children`. `inlineCode` AST nodes (which have a `value` but no `children`) fell through to the default empty- string return, silently dropping their content. For example `**算出 \`logits\`**` rendered as `<strong>算出 </strong>` with the code span completely lost. Add an `inlineCode` branch that wraps the node value in backticks so the downstream `marked` pass can turn it into a proper `<code>` element. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -369,6 +369,7 @@ function preprocessCjkEmphasis(markdown: string): string {
|
||||
const tree = processor.parse(markdown);
|
||||
const extractText = (node: any): string => {
|
||||
if (node.type === "text") return node.value;
|
||||
if (node.type === "inlineCode") return `\`${node.value}\``;
|
||||
if (node.children) return node.children.map(extractText).join("");
|
||||
return "";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user