fix: parsing issues

This commit is contained in:
2026-03-26 11:46:33 +08:00
parent faf179a4fd
commit 0aaf81057a
2 changed files with 43 additions and 12 deletions
+7 -1
View File
@@ -61,7 +61,13 @@ const marked = new Marked()
const match = rule.exec(src);
if (match) {
const yamlContent = match[1]?.trim() || '';
const props = yaml.load(yamlContent) as Record<string, unknown> || {};
let props: Record<string, unknown> = {};
try {
props = (yaml.load(yamlContent) as Record<string, unknown>) || {};
} catch (e) {
console.error("YAML Parse Error in code-block-yaml-tag:", e);
props = { error: "Invalid YAML content" };
}
// 提取 tag 名称,默认为 tag-unknown
const tagName = (props.tag as string) || 'tag-unknown';