Skip to content

Commit

Permalink
fix(markdown): Fix GFM rendering if blank line right after magic keyw…
Browse files Browse the repository at this point in the history
…ord (#11108)
  • Loading branch information
queengooborg authored Jul 19, 2024
1 parent 74d4712 commit 16d7b88
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion markdown/m2h/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 16d7b88

Please sign in to comment.