mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-23 04:35:02 +08:00
feat(export/markdown): export display math properly
This commit is contained in:
parent
894cfe4f7a
commit
fc4eb13e8d
@ -279,10 +279,16 @@ describe("Markdown export", () => {
|
||||
expect(markdownExportService.toMarkdown(html)).toBe(expected);
|
||||
});
|
||||
|
||||
it("converts inline math expressions to proper Markdown syntax", () => {
|
||||
it("converts inline math expressions into proper Markdown syntax", () => {
|
||||
const html = /*html*/`<p>The equation is <span class="math-tex">\(e=mc^{2}\)</span>.</p>`;
|
||||
const expected = `The equation is\u00a0$e=mc^{2}$.`;
|
||||
expect(markdownExportService.toMarkdown(html)).toBe(expected);
|
||||
});
|
||||
|
||||
it("converts display math expressions into proper Markdown syntax", () => {
|
||||
const html = /*html*/`<span class="math-tex">\[\sqrt{x^{2}+1}\]</span>`;
|
||||
const expected = `$$\sqrt{x^{2}+1}$$`;
|
||||
expect(markdownExportService.toMarkdown(html)).toBe(expected);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -219,6 +219,11 @@ function buildMathFilter(): Rule {
|
||||
return `$${content.substring(1, content.length - 1)}$`;
|
||||
}
|
||||
|
||||
// Display math
|
||||
if (content.startsWith("\\[") && content.endsWith("\\]")) {
|
||||
return `$$${content.substring(2, content.length - 2)}$$`;
|
||||
}
|
||||
|
||||
// Unknown.
|
||||
return content;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user