refactor(import/markdown): add guard condition for processing math

This commit is contained in:
Elian Doran 2025-04-05 09:59:42 +03:00
parent e6b9ecda5c
commit 721bf455e1
No known key found for this signature in database

View File

@ -14,6 +14,7 @@ class CustomMarkdownRenderer extends Renderer {
paragraph(data: Tokens.Paragraph): string { paragraph(data: Tokens.Paragraph): string {
let text = super.paragraph(data).trimEnd(); let text = super.paragraph(data).trimEnd();
if (text.includes("$")) {
// Display math // Display math
text = text.replaceAll(/\$\$(.+)\$\$/g, text = text.replaceAll(/\$\$(.+)\$\$/g,
`<span class="math-tex">\\\[$1\\\]</span>`); `<span class="math-tex">\\\[$1\\\]</span>`);
@ -21,6 +22,7 @@ class CustomMarkdownRenderer extends Renderer {
// Inline math // Inline math
text = text.replaceAll(/\$(.+)\$/g, text = text.replaceAll(/\$(.+)\$/g,
`<span class="math-tex">\\\($1\\\)</span>`); `<span class="math-tex">\\\($1\\\)</span>`);
}
return text; return text;
} }