diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index 295234c..7f5262a 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -49,10 +49,12 @@ function highlightHtmlCode(html: string): string { } export function renderArticle(content: string): string { + let html: string if (content.trimStart().startsWith('<')) { - const safe = DOMPurify.sanitize(content) - return highlightHtmlCode(safe) + html = DOMPurify.sanitize(content) + } else { + const rawHtml = marked.parse(content, { async: false }) as string + html = DOMPurify.sanitize(rawHtml) } - const rawHtml = marked.parse(content, { async: false }) as string - return DOMPurify.sanitize(rawHtml) + return highlightHtmlCode(html) } \ No newline at end of file