From 360e6f23c00fabceae4d0252995da2b15627dac8 Mon Sep 17 00:00:00 2001 From: Trang Doan Date: Mon, 15 Dec 2025 10:20:16 -0500 Subject: [PATCH 1/2] preserve list indicator --- apps/obsidian/src/utils/tagNodeHandler.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/obsidian/src/utils/tagNodeHandler.ts b/apps/obsidian/src/utils/tagNodeHandler.ts index b2964c694..b62db5c10 100644 --- a/apps/obsidian/src/utils/tagNodeHandler.ts +++ b/apps/obsidian/src/utils/tagNodeHandler.ts @@ -12,19 +12,23 @@ const HIDE_DELAY = 100; const OBSERVER_RESTART_DELAY = 100; const TOOLTIP_OFFSET = 40; +const LIST_INDICATOR_REGEX = /^(\s*)(\d+\.\s+|-\s+|\*\s+|\+\s+)/; + const sanitizeTitle = (title: string): string => { const invalidChars = /[\\/:]/g; - // Remove list item indicators (numbered, bulleted, etc.) - const listIndicator = /^(\s*)(\d+\.\s+|-\s+|\*\s+|\+\s+)/; - return title - .replace(listIndicator, "") + .replace(LIST_INDICATOR_REGEX, "") .replace(invalidChars, "") .replace(/\s+/g, " ") .trim(); }; +const extractListPrefix = (line: string): string => { + const match = line.match(LIST_INDICATOR_REGEX); + return match ? match[0] : ""; +}; + type ExtractedTagData = { fullLineContent: string; tagName: string; @@ -350,9 +354,11 @@ export class TagNodeHandler { return; } - // Replace the entire line with just the discourse node link + const listPrefix = extractListPrefix(actualLineText); + const replacementText = listPrefix + linkText; + editor.replaceRange( - linkText, + replacementText, { line: lineNumber, ch: 0 }, { line: lineNumber, ch: actualLineText.length }, ); From 5e8c931bdf8ae145a0e6901b28369aa0f7289d63 Mon Sep 17 00:00:00 2001 From: Trang Doan Date: Mon, 15 Dec 2025 12:55:34 -0500 Subject: [PATCH 2/2] address PR comments --- apps/obsidian/src/utils/tagNodeHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/obsidian/src/utils/tagNodeHandler.ts b/apps/obsidian/src/utils/tagNodeHandler.ts index b62db5c10..5b955714a 100644 --- a/apps/obsidian/src/utils/tagNodeHandler.ts +++ b/apps/obsidian/src/utils/tagNodeHandler.ts @@ -12,7 +12,7 @@ const HIDE_DELAY = 100; const OBSERVER_RESTART_DELAY = 100; const TOOLTIP_OFFSET = 40; -const LIST_INDICATOR_REGEX = /^(\s*)(\d+\.\s+|-\s+|\*\s+|\+\s+)/; +const LIST_INDICATOR_REGEX = /^(\s*)(\d+[.)]\s+|[-*+]\s+(?:\[[ xX]\]\s+)?)/; const sanitizeTitle = (title: string): string => { const invalidChars = /[\\/:]/g;