From 16d7b88f13173a2eedd531a3da58c8b3fcf9c599 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 19 Jul 2024 02:07:23 -0700 Subject: [PATCH] fix(markdown): Fix GFM rendering if blank line right after magic keyword (#11108) --- markdown/m2h/handlers/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/markdown/m2h/handlers/index.ts b/markdown/m2h/handlers/index.ts index 440b39e1f771..2e4a1a224850 100644 --- a/markdown/m2h/handlers/index.ts +++ b/markdown/m2h/handlers/index.ts @@ -120,7 +120,7 @@ export function buildLocalizedHandlers(locale: Locale): Handlers { if (type.isGFM) { // Handle GFM proposed syntax node.children[0].children[0].value = - node.children[0].children[0].value.replace(/\[!\w+\]\n/, ""); + node.children[0].children[0].value.replace(/\[!\w+\]\n?/, ""); // If the type isn't a callout, add the magic keyword if (!isCallout) { @@ -137,6 +137,14 @@ export function buildLocalizedHandlers(locale: Locale): Handlers { (["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 if (isCallout) {