diff --git a/src/services/export/markdown.spec.ts b/src/services/export/markdown.spec.ts index 2726481af..24aa77da2 100644 --- a/src/services/export/markdown.spec.ts +++ b/src/services/export/markdown.spec.ts @@ -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*/`
The equation is \(e=mc^{2}\).
`; 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*/`\[\sqrt{x^{2}+1}\]`; + const expected = `$$\sqrt{x^{2}+1}$$`; + expect(markdownExportService.toMarkdown(html)).toBe(expected); + }); + }); diff --git a/src/services/export/markdown.ts b/src/services/export/markdown.ts index cbc480984..731024435 100644 --- a/src/services/export/markdown.ts +++ b/src/services/export/markdown.ts @@ -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; }