From 4da6b40d29b409ef83c7403eb16eb02a1878b253 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 14 Feb 2026 13:02:15 -0500 Subject: [PATCH] add more link cases for regex, remove underline --- source/task-list-view.tsx | 2 +- source/utils.ts | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/task-list-view.tsx b/source/task-list-view.tsx index ef3a0d8..1832a3d 100644 --- a/source/task-list-view.tsx +++ b/source/task-list-view.tsx @@ -16,7 +16,7 @@ function Content({text}: {text: string}) { {segments.map((seg, i) => seg.type === 'link' ? ( - {seg.text} + {seg.text} ) : ( {seg.text} diff --git a/source/utils.ts b/source/utils.ts index ace5999..c2f3b3b 100644 --- a/source/utils.ts +++ b/source/utils.ts @@ -17,17 +17,26 @@ export type ContentSegment = export function parseMdLink(content: string): ContentSegment[] { const segments: ContentSegment[] = []; - const linkPattern = /\[([^\]]+)\]\(([^)]+)\)/g; + const linkPattern = + /\[((?:\[[^\]]*\]|[^\]])+)\]\(([^)]+)\)|(https?:\/\/[^\s)]+)/g; let lastIndex = 0; let match; while ((match = linkPattern.exec(content)) !== null) { if (match.index > lastIndex) { - segments.push({type: 'text', text: content.slice(lastIndex, match.index)}); + segments.push({ + type: 'text', + text: content.slice(lastIndex, match.index), + }); + } + + if (match[1] && match[2]) { + segments.push({type: 'link', text: match[1], url: match[2]}); + } else if (match[3]) { + segments.push({type: 'link', text: match[3], url: match[3]}); } - segments.push({type: 'link', text: match[1]!, url: match[2]!}); lastIndex = match.index + match[0].length; } @@ -37,4 +46,3 @@ export function parseMdLink(content: string): ContentSegment[] { return segments; } - -- 2.51.2