From 2caddbc8fd8469330f7fcf20c9cc20f038ff9423 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 17 Sep 2024 15:14:50 -0500 Subject: [PATCH] fix: Remove legacy title format --- src/lib/markdown.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/markdown.js b/src/lib/markdown.js index de9509e..8a37276 100644 --- a/src/lib/markdown.js +++ b/src/lib/markdown.js @@ -3,7 +3,6 @@ Remark and rehype functions */ import { visit } from 'unist-util-visit'; const alertRegex = /^:>(NOTE|TIP|IMPORTANT|WARNING|CAUTION)/i; -const alertLegacyRegex = /^:>(NOTE|TIP|IMPORTANT|WARNING|CAUTION)(\/.*)?/i; /** * Alerts are a Markdown extension based on the blockquote syntax that you can use to emphasize critical information. * On GitHub, they are displayed with distinctive colors and icons to indicate the significance of the content. @@ -11,7 +10,7 @@ const alertLegacyRegex = /^:>(NOTE|TIP|IMPORTANT|WARNING|CAUTION)(\/.*)?/i; * * This is adapted from `remark-github-blockquote-alert` */ -function remarkAlert/*: Plugin<[Option?], Root> = */({ legacyTitle = false } = {}) /*=>*/ { +function remarkAlert/*: Plugin<[Option?], Root> = */() /*=>*/ { return (tree) => { visit(tree, "blockquote", (node, index, parent) => { let alertType = ''; @@ -21,12 +20,12 @@ function remarkAlert/*: Plugin<[Option?], Root> = */({ legacyTitle = false } = { if (isNext && item.type === "paragraph") { const firstNode = item.children[0]; const text = firstNode.type === 'text' ? firstNode.value : ''; - const reg = legacyTitle ? alertLegacyRegex : alertRegex; + const reg = alertRegex; const match = text.match(reg); if (match) { isNext = false; alertType = match[1].toLocaleLowerCase(); - title = legacyTitle ? match[2] || alertType.toLocaleUpperCase() : alertType.toLocaleUpperCase(); + title = alertType.toLocaleUpperCase(); if (text.includes('\n')) { item.children[0] = { type: 'text',