From 53d7fcee1f6b90cf603b464839a602f2b73e1383 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 26 Jul 2024 09:36:12 -0700 Subject: [PATCH] fix(markdown): Always render noteblock titles on its own line --- markdown/m2h/handlers/index.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/markdown/m2h/handlers/index.ts b/markdown/m2h/handlers/index.ts index 2e4a1a224850..97d14c27cc14 100644 --- a/markdown/m2h/handlers/index.ts +++ b/markdown/m2h/handlers/index.ts @@ -122,9 +122,17 @@ export function buildLocalizedHandlers(locale: Locale): Handlers { node.children[0].children[0].value = node.children[0].children[0].value.replace(/\[!\w+\]\n?/, ""); + // Remove blank line if there is one + if ( + node.children[0].children.length === 1 && + node.children[0].children[0].value === "" + ) { + node.children.splice(0, 1); + } + // If the type isn't a callout, add the magic keyword if (!isCallout) { - node.children[0].children.unshift({ + node.children.unshift({ type: "strong", children: [ { @@ -132,21 +140,13 @@ export function buildLocalizedHandlers(locale: Locale): Handlers { value: type.magicKeyword, }, ], + properties: { + className: ["notecard-title"], + }, }); - node.children[0].children[1].value = - (["zh-CN", "zh-TW"].includes(locale) ? "" : " ") + - node.children[0].children[1].value; - } - - // Remove blank line if there is one - if ( - node.children[0].children.length === 1 && - node.children[0].children[0].value === "" - ) { - node.children.splice(0, 1); } } else { - // Remove "Callout:" text + // Remove "Callout:" text from non-GFM notecard if (isCallout) { if (node.children[0].children.length <= 1) { node.children.splice(0, 1);