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;
}
-