Skip to content

Build your personal knowledge base with Trilium Notes

feat(import): strip the @ prefix from Notion inline date mentions

Elian Doran2fdb2587b829
diff --git a/packages/trilium-core/src/services/import/notion/converter.spec.ts b/packages/trilium-core/src/services/import/notion/converter.spec.ts
index e7489eee99..2640a0ec69 100644
--- a/packages/trilium-core/src/services/import/notion/converter.spec.ts
+++ b/packages/trilium-core/src/services/import/notion/converter.spec.ts
@@ -166,3 +166,13 @@ describe("convertNotionHtml — bookmarks", () => {
);
});
});
+
+describe("convertNotionHtml — date mentions", () => {
+ it("strips the @ prefix Notion puts on inline <time> date mentions", () => {
+ expect(convertNotionHtml(`<p><time>@June 21, 2026</time></p>`)).toBe(`<p><time>June 21, 2026</time></p>`);
+ });
+
+ it("leaves date text without an @ untouched", () => {
+ expect(convertNotionHtml(`<p><time>June 21, 2026</time></p>`)).toBe(`<p><time>June 21, 2026</time></p>`);
+ });
+});
diff --git a/packages/trilium-core/src/services/import/notion/converter.ts b/packages/trilium-core/src/services/import/notion/converter.ts
index e9e4ca54a0..ad02263475 100644
--- a/packages/trilium-core/src/services/import/notion/converter.ts
+++ b/packages/trilium-core/src/services/import/notion/converter.ts
@@ -13,6 +13,7 @@ import { HTMLElement, parse } from "node-html-parser";
export function convertNotionHtml(html: string): string {
const root = parse(html);
convertMath(root);
+ stripDatePrefixes(root);
convertTodoLists(root);
convertToggles(root);
unwrapDisplayContents(root);
@@ -80,6 +81,19 @@ function convertMath(root: HTMLElement) {
}
}
+/**
+ * Notion prefixes its inline date mentions with "@" (e.g. `<time>@June 21, 2026</time>`). Strip it so the
+ * imported text reads naturally, mirroring how the importer already handles property-row date metadata.
+ */
+function stripDatePrefixes(root: HTMLElement) {
+ for (const time of root.querySelectorAll("time")) {
+ const text = time.textContent;
+ if (text?.includes("@")) {
+ time.set_content(text.replace(/@/g, ""));
+ }
+ }
+}
+
/** Notion's default callout icon; it maps 1:1 to a "tip" admonition, so the emoji itself is redundant. */
const DEFAULT_CALLOUT_EMOJI = "💡";