refactor: remove double replace for markdown (#12706)

This commit is contained in:
Barthélémy Ledoux
2025-11-06 11:58:15 +01:00
committed by GitHub
parent 8947fec1a4
commit 686c99f09a

View File

@@ -68,19 +68,6 @@
const fontSizeCss = computed(() => `var(--${props.fontSizeVar})`);
const hasMatches = computed(() => hasMatchesRef.value);
/**
* Replace custom alert syntax (legacy component behavior)
* ::alert{type="info"} ... ::: -> ::: info ... :::
*/
function replaceAlertSyntax(source: string | undefined) {
if (!source) return "";
return source.replace(
/(\n)?:\s*:\s*alert\{type="(.*?)"\}\s*\n([\s\S]*?)\n:\s*:(\n)?/g,
(_, newLine1, type, content, newLine2) =>
`${newLine1 ?? ""}::: ${type}\n${content}\n:::${newLine2 ?? ""}`
);
}
/**
* RENDERING
*/
@@ -109,9 +96,7 @@
return;
}
const source = replaceAlertSyntax(props.source);
markdownHtml.value = await Markdown.render(source, {
markdownHtml.value = await Markdown.render(props.source, {
permalink: props.permalink,
html: props.html,
variant: props.variant,