mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 18:42:28 +08:00
feat(import/markdown): import in-line math properly
This commit is contained in:
parent
07b5cd3b05
commit
e6b9ecda5c
@ -165,7 +165,7 @@ second line 2</code></pre><ul><li>Hello</li><li>world</li></ul><ol><li>Hello</li
|
|||||||
|
|
||||||
it("converts inline math expressions into Mathtex format", () => {
|
it("converts inline math expressions into Mathtex format", () => {
|
||||||
const input = `The equation is\u00a0$e=mc^{2}$.`;
|
const input = `The equation is\u00a0$e=mc^{2}$.`;
|
||||||
const expected = /*html*/`<p>The equation is <span class="math-tex">\(e=mc^{2}\)</span>.</p>`;
|
const expected = /*html*/`<p>The equation is <span class="math-tex">\\(e=mc^{2}\\)</span>.</p>`;
|
||||||
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ class CustomMarkdownRenderer extends Renderer {
|
|||||||
text = text.replaceAll(/\$\$(.+)\$\$/g,
|
text = text.replaceAll(/\$\$(.+)\$\$/g,
|
||||||
`<span class="math-tex">\\\[$1\\\]</span>`);
|
`<span class="math-tex">\\\[$1\\\]</span>`);
|
||||||
|
|
||||||
|
// Inline math
|
||||||
|
text = text.replaceAll(/\$(.+)\$/g,
|
||||||
|
`<span class="math-tex">\\\($1\\\)</span>`);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user