Skip to content

Build your personal knowledge base with Trilium Notes

fix(import): keep the start and reversed attributes on ordered lists

Elian Doran72005b8fc459
diff --git a/packages/trilium-core/src/services/import/markdown.spec.ts b/packages/trilium-core/src/services/import/markdown.spec.ts
index efca48228b..ede36413f0 100644
--- a/packages/trilium-core/src/services/import/markdown.spec.ts
+++ b/packages/trilium-core/src/services/import/markdown.spec.ts
@@ -451,6 +451,15 @@ $$`;
}
});
+ it("keeps the starting number of an ordered list, including through the Markdown exporter", () => {
+ const input = trimIndentation`\
+ 3. Third
+ 4. Fourth`;
+ const expected = `<ol start="3"><li>Third</li><li>Fourth</li></ol>`;
+ expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
+ expect(markdownService.renderToHtml(markdownExportService.toMarkdown(expected), "Title")).toStrictEqual(expected);
+ });
+
it("imports todo list multistate markers as data-trilium-task-state and titles the <li> with the state's human name", () => {
// The `title` attribute mirrors what the CKEditor data downcast emits — it's
// the hover tooltip viewers of the shared page, the read-only preview and
diff --git a/packages/trilium-core/src/services/sanitizer.spec.ts b/packages/trilium-core/src/services/sanitizer.spec.ts
index a10a4da29b..b8b0c53c4d 100644
--- a/packages/trilium-core/src/services/sanitizer.spec.ts
+++ b/packages/trilium-core/src/services/sanitizer.spec.ts
@@ -64,6 +64,11 @@ describe("sanitize", () => {
expect(sanitizeHtml(dirty)).toBe(dirty);
});
+ it("keeps the start and reversed attributes on <ol> (CKEditor list properties)", () => {
+ const dirty = `<ol start="3"><li>Third</li></ol><ol reversed><li>Last</li></ol><ol reversed start="10"><li>Ten</li></ol>`;
+ expect(sanitizeHtml(dirty)).toBe(dirty);
+ });
+
it("keeps the scope attribute on table header cells", () => {
const dirty = `<table><thead><tr><th scope="col">C</th></tr></thead><tbody><tr><th scope="row">R</th><td>A</td></tr></tbody></table>`;
expect(sanitizeHtml(dirty)).toBe(dirty);
diff --git a/packages/trilium-core/src/services/sanitizer.ts b/packages/trilium-core/src/services/sanitizer.ts
index 2692880cb2..ee2645f629 100644
--- a/packages/trilium-core/src/services/sanitizer.ts
+++ b/packages/trilium-core/src/services/sanitizer.ts
@@ -46,6 +46,7 @@ export function sanitizeHtml(dirtyHtml: string) {
a: ["id"],
h2: ["id"],
li: ["id"],
+ ol: ["start", "reversed"],
// Collapsible blocks: keep the native open/closed state (e.g. preserved from a Notion import)
// so the published/share view, which renders this HTML directly, reflects it.
details: ["open"],