Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down