From c34e6f1957a94c4132717f46061770c8bb36c996 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Wed, 18 Mar 2026 13:58:16 +0000 Subject: [PATCH] Strip all {{...}} macros from blocks before indexing Generalize the embed-only macro regex to strip all Logseq macros (query, renderer, cloze, etc.) from block content during normalization. Co-Authored-By: Claude Opus 4.6 --- src/__tests__/utils.test.ts | 4 +++- src/utils.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/__tests__/utils.test.ts b/src/__tests__/utils.test.ts index 1d09e4e..3bb9ee9 100644 --- a/src/__tests__/utils.test.ts +++ b/src/__tests__/utils.test.ts @@ -14,11 +14,13 @@ describe("normalizeContent", () => { ); }); - it("strips embed macros", () => { + it("strips macros", () => { expect(normalizeContent("Before {{embed ((abc-123))}} after")).toBe( "Before after", ); expect(normalizeContent("{{embed [[Some Page]]}}")).toBe(""); + expect(normalizeContent("Results: {{query (property :type \"book\")}}")).toBe("Results:"); + expect(normalizeContent("{{renderer :todomaster}}")).toBe(""); }); it("strips markdown link URLs, keeps bracketed text", () => { diff --git a/src/utils.ts b/src/utils.ts index c4a4e10..dd8c400 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,8 +8,8 @@ export function normalizeContent(content: string): string { // Strip Logseq block references ((uuid)) text = text.replace(/\(\([0-9a-fA-F-]+\)\)/g, ""); - // Strip Logseq embed macros {{embed ...}} - text = text.replace(/\{\{embed\s[^}]*\}\}/g, ""); + // Strip Logseq macros {{embed ...}}, {{query ...}}, {{renderer ...}}, etc. + text = text.replace(/\{\{[^}]*\}\}/g, ""); // Strip raw URLs from images, but PRESERVE the alt text // ![Diagram of architecture](https://...) -> Diagram of architecture