Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
test(markdown export): stop asserting environment-dependent attribute escaping
Elian Dorand6266f17cf6a
diff --git a/packages/trilium-core/src/services/export/markdown.spec.ts b/packages/trilium-core/src/services/export/markdown.spec.tsindex 8b57629d12..2ad224b8ce 100644--- a/packages/trilium-core/src/services/export/markdown.spec.ts+++ b/packages/trilium-core/src/services/export/markdown.spec.ts@@ -114,10 +114,16 @@ describe("Markdown export", () => {'<section class="link-embed" data-url="https://e.com/?a=1&b=2" data-embed-type="opengraph" data-title="A & B <x>"></section>');- expect(exported).toBe(- '<section class="link-embed" data-url="https://e.com/?a=1&b=2" data-embed-type="opengraph" data-title="A & B <x>">' +- '<a href="https://e.com/?a=1&b=2">A & B <x></a></section>'- );+ // The fallback anchor is generated from the data attributes, so its href and title must be+ // HTML-escaped or a title like `A & B <x>` would break the exported markup. This escaping is+ // done deterministically with escape-html, so it holds under both test environments.+ expect(exported).toContain('<a href="https://e.com/?a=1&b=2">A & B <x></a>');++ // The section wrapper and its data attributes survive so the preview re-imports losslessly.+ // The escaping of `<`/`>` inside data-title is left to turndown's serializer, which differs by+ // environment (server/node uses domino and escapes them; standalone/happy-dom uses the browser+ // serializer and leaves them raw). It is not asserted because both forms decode to the same value.+ expect(exported).toContain('<section class="link-embed" data-url="https://e.com/?a=1&b=2" data-embed-type="opengraph"');});it("exports strikethrough text correctly", () => {