Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

feat(property-panel): render embedded links inside frontmatter property values (#1889)

Abrahamc5464a663829
diff --git a/packages/app/src/components/PropertyInlineLinks.dom.test.tsx b/packages/app/src/components/PropertyInlineLinks.dom.test.tsx
new file mode 100644
index 000000000..6a4b28def
--- /dev/null
+++ b/packages/app/src/components/PropertyInlineLinks.dom.test.tsx
@@ -0,0 +1,95 @@
+import { afterEach, describe, expect, test } from 'bun:test';
+import { cleanup, render, screen } from '@testing-library/react';
+import { PropertyInlineLinks } from './PropertyInlineLinks';
+
+afterEach(() => {
+ cleanup();
+});
+
+describe('PropertyInlineLinks — wikilink rendering', () => {
+ test('wikilink target lands on the SPA hash route', () => {
+ render(<PropertyInlineLinks text="[[some/page]] — note" />);
+ const a = screen.getByTestId('property-inline-wikilink') as HTMLAnchorElement;
+ expect(a.getAttribute('href')).toBe('#/some/page');
+ expect(a.getAttribute('data-target')).toBe('some/page');
+ expect(screen.getByTestId('property-inline-links').textContent).toBe('some/page — note');
+ });
+
+ test('wikilink with anchor encodes the anchor onto the hash', () => {
+ render(<PropertyInlineLinks text="[[page#heading]]" />);
+ const a = screen.getByTestId('property-inline-wikilink') as HTMLAnchorElement;
+ expect(a.getAttribute('href')).toBe('#/page#heading');
+ });
+
+ test('wikilink with alias displays the alias as the visible label', () => {
+ render(<PropertyInlineLinks text="[[some/page|Custom Label]]" />);
+ const a = screen.getByTestId('property-inline-wikilink');
+ expect(a.textContent).toBe('Custom Label');
+ expect(a.getAttribute('data-target')).toBe('some/page');
+ });
+
+ test('wikilink path with `/` segments encodes each segment individually', () => {
+ render(<PropertyInlineLinks text="[[a b/c d]]" />);
+ const a = screen.getByTestId('property-inline-wikilink') as HTMLAnchorElement;
+ expect(a.getAttribute('href')).toBe('#/a%20b/c%20d');
+ });
+});
+
+describe('PropertyInlineLinks — markdown links and autolinks', () => {
+ test('markdown link renders text as the visible label', () => {
+ render(<PropertyInlineLinks text="see [the page](https://example.com) here" />);
+ const a = screen.getByTestId('property-inline-link') as HTMLAnchorElement;
+ expect(a.getAttribute('href')).toBe('https://example.com');
+ expect(a.textContent).toBe('the page');
+ expect(screen.getByTestId('property-inline-links').textContent).toBe('see the page here');
+ });
+
+ test('bare http(s) URL renders as autolink showing the full URL', () => {
+ render(<PropertyInlineLinks text="visit https://example.com today" />);
+ const a = screen.getByTestId('property-inline-autolink') as HTMLAnchorElement;
+ expect(a.getAttribute('href')).toBe('https://example.com');
+ expect(a.textContent).toBe('https://example.com');
+ });
+});
+
+describe('PropertyInlineLinks — plain-text fast path', () => {
+ test('plain text renders a single span with no link-component test-id', () => {
+ const { container } = render(<PropertyInlineLinks text="just plain words" />);
+ expect(screen.queryByTestId('property-inline-links')).toBeNull();
+ expect(screen.queryByTestId('property-inline-wikilink')).toBeNull();
+ expect(screen.queryByTestId('property-inline-link')).toBeNull();
+ expect(screen.queryByTestId('property-inline-autolink')).toBeNull();
+ expect(container.textContent).toBe('just plain words');
+ });
+
+ test('empty string renders an empty span', () => {
+ const { container } = render(<PropertyInlineLinks text="" />);
+ expect(container.textContent).toBe('');
+ });
+
+ test('text containing the substring `[[` but no wikilink → fast path', () => {
+ const { container } = render(<PropertyInlineLinks text="literal [[]] sequence" />);
+ expect(screen.queryByTestId('property-inline-links')).toBeNull();
+ expect(container.textContent).toBe('literal [[]] sequence');
+ });
+});
+
+describe('PropertyInlineLinks — mixed content', () => {
+ test('PRD-7111 reported shape — wikilink + em-dash + parenthetical text', () => {
+ const input =
+ '[[public/open-knowledge/specs/2026-06-12-showall-truncation-ux/SPEC]] — which entries appear (cap), NOT horizontal density';
+ render(<PropertyInlineLinks text={input} />);
+ const a = screen.getByTestId('property-inline-wikilink');
+ expect(a.textContent).toBe('public/open-knowledge/specs/2026-06-12-showall-truncation-ux/SPEC');
+ expect(screen.getByTestId('property-inline-links').textContent).toBe(
+ 'public/open-knowledge/specs/2026-06-12-showall-truncation-ux/SPEC — which entries appear (cap), NOT horizontal density',
+ );
+ });
+
+ test('mixed wikilink + markdown link + autolink in one string', () => {
+ render(<PropertyInlineLinks text="see [[Page]] and [doc](./d.md) plus https://example.com" />);
+ expect(screen.getByTestId('property-inline-wikilink').textContent).toBe('Page');
+ expect(screen.getByTestId('property-inline-link').textContent).toBe('doc');
+ expect(screen.getByTestId('property-inline-autolink').textContent).toBe('https://example.com');
+ });
+});
diff --git a/packages/app/src/components/PropertyInlineLinks.tsx b/packages/app/src/components/PropertyInlineLinks.tsx
new file mode 100644
index 000000000..0e9411c96
--- /dev/null
+++ b/packages/app/src/components/PropertyInlineLinks.tsx
@@ -0,0 +1,106 @@
+import type { ReactNode } from 'react';
+import { dispatchExternalLinkClick } from '@/lib/external-link';
+import { cn } from '@/lib/utils';
+import {
+ hasInlineLinks,
+ type PropertyInlineSegment,
+ tokenizePropertyInlineLinks,
+} from './property-inline-link-tokens';
+
+function hashFromTarget(target: string, anchor: string | null): string {
+ const docHash = target
+ .split('/')
+ .map((part) => encodeURIComponent(part))
+ .join('/');
+ const anchorSuffix = anchor ? `#${encodeURIComponent(anchor)}` : '';
+ return `#/${docHash}${anchorSuffix}`;
+}
+
+interface PropertyInlineLinksProps {
+ text: string;
+ className?: string;
+}
+
+export function PropertyInlineLinks({ text, className }: PropertyInlineLinksProps): ReactNode {
+ if (!hasInlineLinks(text)) {
+ return <span className={className}>{text}</span>;
+ }
+
+ const segments = tokenizePropertyInlineLinks(text);
+ return (
+ <span className={className} data-testid="property-inline-links">
+ {segments.map((seg, i) => renderSegment(seg, i))}
+ </span>
+ );
+}
+
+function renderSegment(seg: PropertyInlineSegment, index: number): ReactNode {
+ const key = index;
+ switch (seg.type) {
+ case 'text':
+ return <span key={key}>{seg.value}</span>;
+
+ case 'wikilink': {
+ const label = seg.alias ?? (seg.anchor ? `${seg.target}#${seg.anchor}` : seg.target);
+ return (
+ <a
+ key={key}
+ href={hashFromTarget(seg.target, seg.anchor)}
+ data-testid="property-inline-wikilink"
+ data-target={seg.target}
+ title={seg.target}
+ className={cn(
+ 'rounded-sm px-0.5 text-azure-blue underline decoration-azure-blue/40 underline-offset-2 hover:decoration-azure-blue dark:text-sky-blue dark:decoration-sky-blue/40 dark:hover:decoration-sky-blue',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
+ )}
+ >
+ {label}
+ </a>
+ );
+ }
+
+ case 'link':
+ return (
+ <a
+ key={key}
+ href={seg.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ data-testid="property-inline-link"
+ onClick={(e) => dispatchExternalLinkClick(e, seg.url)}
+ onAuxClick={(e) => {
+ if (e.button === 1) dispatchExternalLinkClick(e, seg.url);
+ }}
+ title={seg.url}
+ className={cn(
+ 'text-azure-blue underline decoration-azure-blue/40 underline-offset-2 hover:decoration-azure-blue dark:text-sky-blue dark:decoration-sky-blue/40 dark:hover:decoration-sky-blue',
+ 'focus-visible:outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-ring',
+ )}
+ >
+ {seg.text}
+ </a>
+ );
+
+ case 'autolink':
+ return (
+ <a
+ key={key}
+ href={seg.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ data-testid="property-inline-autolink"
+ onClick={(e) => dispatchExternalLinkClick(e, seg.url)}
+ onAuxClick={(e) => {
+ if (e.button === 1) dispatchExternalLinkClick(e, seg.url);
+ }}
+ title={seg.url}
+ className={cn(
+ 'text-azure-blue underline decoration-azure-blue/40 underline-offset-2 hover:decoration-azure-blue dark:text-sky-blue dark:decoration-sky-blue/40 dark:hover:decoration-sky-blue',
+ 'focus-visible:outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-ring',
+ )}
+ >
+ {seg.url}
+ </a>
+ );
+ }
+}
diff --git a/packages/app/src/components/PropertyWidgets.tsx b/packages/app/src/components/PropertyWidgets.tsx
index fe7a90e1a..6a5877af0 100644
--- a/packages/app/src/components/PropertyWidgets.tsx
+++ b/packages/app/src/components/PropertyWidgets.tsx
@@ -38,6 +38,8 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
import { dispatchTagClickEvent } from '@/editor/extensions/tag-click-plugin';
import { dispatchExternalLinkClick } from '@/lib/external-link';
import { cn } from '@/lib/utils';
+import { PropertyInlineLinks } from './PropertyInlineLinks';
+import { hasInlineLinks } from './property-inline-link-tokens';
export interface CommonWidgetProps<T extends FrontmatterValue> {
keyName: string;
@@ -64,8 +66,9 @@ export function TextWidget({ keyName, value, onCommit }: CommonWidgetProps<strin
}, [isEditing]);
const trimmedValue = value.trim();
- const isLinkValue = !isEditing && trimmedValue.length > 0 && /^https?:\/\//i.test(trimmedValue);
- if (isLinkValue) {
+ const isPureUrl = !isEditing && trimmedValue.length > 0 && /^https?:\/\/\S+$/i.test(trimmedValue);
+ const hasMixedLinks = !isEditing && !isPureUrl && hasInlineLinks(value);
+ if (isPureUrl) {
return (
<div data-testid="link-widget" data-key={keyName} className="group flex items-center gap-1">
<a
@@ -97,6 +100,35 @@ export function TextWidget({ keyName, value, onCommit }: CommonWidgetProps<strin
);
}
+ if (hasMixedLinks) {
+ return (
+ <div
+ data-testid="mixed-link-widget"
+ data-key={keyName}
+ className="group flex items-center gap-1"
+ >
+ <div
+ data-testid="mixed-link-widget-display"
+ title={value}
+ className="block min-w-0 flex-1 truncate px-2 py-1 text-sm leading-tight"
+ >
+ <PropertyInlineLinks text={value} />
+ </div>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ aria-label={t`Edit ${keyName}`}
+ onClick={() => setIsEditing(true)}
+ data-testid="mixed-link-widget-edit"
+ className="text-muted-foreground/0 hover:text-foreground focus-visible:text-muted-foreground group-hover:text-muted-foreground/60"
+ >
+ <Pencil className="size-3.5" aria-hidden />
+ </Button>
+ </div>
+ );
+ }
+
return (
<textarea
ref={textareaRef}
@@ -394,7 +426,7 @@ export function ListWidget({ keyName, value, onCommit }: CommonWidgetProps<strin
#{chip}
</button>
) : (
- <span>{chip}</span>
+ <PropertyInlineLinks text={chip} />
)}
<button
type="button"
diff --git a/packages/app/src/components/property-inline-link-tokens.test.ts b/packages/app/src/components/property-inline-link-tokens.test.ts
new file mode 100644
index 000000000..73437ff6a
--- /dev/null
+++ b/packages/app/src/components/property-inline-link-tokens.test.ts
@@ -0,0 +1,253 @@
+import { describe, expect, test } from 'bun:test';
+import {
+ hasInlineLinks,
+ type PropertyInlineSegment,
+ tokenizePropertyInlineLinks,
+} from './property-inline-link-tokens';
+
+/** Reconstruct the original source from the segment array — every test
+ * asserts this round-trips losslessly. */
+function reassemble(segments: PropertyInlineSegment[]): string {
+ return segments.map((seg) => (seg.type === 'text' ? seg.value : seg.raw)).join('');
+}
+
+function expectRoundTrip(input: string, segments: PropertyInlineSegment[]): void {
+ expect(reassemble(segments)).toBe(input);
+}
+
+describe('tokenizePropertyInlineLinks — wiki-links', () => {
+ test('bare wikilink at the start, followed by trailing prose', () => {
+ const input = '[[Some/Page]] — description';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([
+ {
+ type: 'wikilink',
+ raw: '[[Some/Page]]',
+ target: 'Some/Page',
+ alias: null,
+ anchor: null,
+ },
+ { type: 'text', value: ' — description' },
+ ]);
+ expectRoundTrip(input, segs);
+ });
+
+ test('wikilink with alias', () => {
+ const input = '[[Some/Page|My Alias]]';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toHaveLength(1);
+ expect(segs[0]).toEqual({
+ type: 'wikilink',
+ raw: '[[Some/Page|My Alias]]',
+ target: 'Some/Page',
+ alias: 'My Alias',
+ anchor: null,
+ });
+ });
+
+ test('wikilink with anchor', () => {
+ const input = '[[Some/Page#heading-slug]]';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs[0]).toEqual({
+ type: 'wikilink',
+ raw: '[[Some/Page#heading-slug]]',
+ target: 'Some/Page',
+ alias: null,
+ anchor: 'heading-slug',
+ });
+ });
+
+ test('multiple wikilinks separated by prose', () => {
+ const input = '[[A]] and [[B|alias]] together';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs.map((s) => s.type)).toEqual(['wikilink', 'text', 'wikilink', 'text']);
+ expectRoundTrip(input, segs);
+ });
+
+ test('PRD-7111 reported shape — wikilink + em-dash + parenthetical', () => {
+ const input =
+ '[[public/open-knowledge/specs/2026-06-12-showall-truncation-ux/SPEC]] — which entries appear (cap), NOT horizontal density';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs[0]).toEqual({
+ type: 'wikilink',
+ raw: '[[public/open-knowledge/specs/2026-06-12-showall-truncation-ux/SPEC]]',
+ target: 'public/open-knowledge/specs/2026-06-12-showall-truncation-ux/SPEC',
+ alias: null,
+ anchor: null,
+ });
+ expectRoundTrip(input, segs);
+ });
+
+ test('empty wikilink `[[]]` is not a wikilink — renders as plain text', () => {
+ const input = '[[]]';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([{ type: 'text', value: '[[]]' }]);
+ });
+
+ test('unbalanced `[[Page` falls through to text', () => {
+ const input = 'lead [[Page in middle';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([{ type: 'text', value: 'lead [[Page in middle' }]);
+ });
+});
+
+describe('tokenizePropertyInlineLinks — markdown links', () => {
+ test('bare markdown link', () => {
+ const input = '[label](https://example.com)';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([
+ {
+ type: 'link',
+ raw: '[label](https://example.com)',
+ text: 'label',
+ url: 'https://example.com',
+ },
+ ]);
+ });
+
+ test('markdown link embedded in prose', () => {
+ const input = 'see [the page](./foo.md) for details';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs.map((s) => s.type)).toEqual(['text', 'link', 'text']);
+ expectRoundTrip(input, segs);
+ });
+
+ test('relative markdown link', () => {
+ const input = '[doc](./folder/doc.md)';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([
+ { type: 'link', raw: '[doc](./folder/doc.md)', text: 'doc', url: './folder/doc.md' },
+ ]);
+ });
+
+ test('malformed: missing `(` after `]` — falls through to text', () => {
+ const input = '[label] no paren';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([{ type: 'text', value: '[label] no paren' }]);
+ });
+
+ test('malformed: missing closing `)` — link rejected, but bare URL still recognized', () => {
+ const input = '[label](https://example.com';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([
+ { type: 'text', value: '[label](' },
+ { type: 'autolink', raw: 'https://example.com', url: 'https://example.com' },
+ ]);
+ });
+
+ test('empty URL `[text]()` — falls through to text', () => {
+ const input = '[text]()';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([{ type: 'text', value: '[text]()' }]);
+ });
+
+ test('nested `[` inside text — falls through to text', () => {
+ const input = '[a [b] c](url)';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([{ type: 'text', value: '[a [b] c](url)' }]);
+ });
+});
+
+describe('tokenizePropertyInlineLinks — bare URLs (autolinks)', () => {
+ test('bare URL renders as autolink', () => {
+ const input = 'https://example.com';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([
+ { type: 'autolink', raw: 'https://example.com', url: 'https://example.com' },
+ ]);
+ });
+
+ test('http (not https) also recognized', () => {
+ const input = 'http://example.com/path';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs[0]).toEqual({
+ type: 'autolink',
+ raw: 'http://example.com/path',
+ url: 'http://example.com/path',
+ });
+ });
+
+ test('bare URL embedded in prose', () => {
+ const input = 'visit https://example.com today';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs.map((s) => s.type)).toEqual(['text', 'autolink', 'text']);
+ expectRoundTrip(input, segs);
+ });
+
+ test('trailing punctuation stripped from URL', () => {
+ const input = 'see https://example.com.';
+ const segs = tokenizePropertyInlineLinks(input);
+ const autolink = segs.find((s) => s.type === 'autolink');
+ expect(autolink).toBeDefined();
+ if (autolink?.type !== 'autolink') throw new Error('unreachable');
+ expect(autolink.url).toBe('https://example.com');
+ expectRoundTrip(input, segs);
+ });
+
+ test('URL with balanced parens kept whole', () => {
+ const input = 'https://en.wikipedia.org/wiki/Foo_(disambiguation)';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([
+ {
+ type: 'autolink',
+ raw: 'https://en.wikipedia.org/wiki/Foo_(disambiguation)',
+ url: 'https://en.wikipedia.org/wiki/Foo_(disambiguation)',
+ },
+ ]);
+ });
+
+ test('URL inside parentheses — trailing `)` stripped (no matching `(` in URL)', () => {
+ const input = 'as documented (see https://example.com) for details';
+ const segs = tokenizePropertyInlineLinks(input);
+ const autolink = segs.find((s) => s.type === 'autolink');
+ expect(autolink).toBeDefined();
+ if (autolink?.type !== 'autolink') throw new Error('unreachable');
+ expect(autolink.url).toBe('https://example.com');
+ expectRoundTrip(input, segs);
+ });
+});
+
+describe('tokenizePropertyInlineLinks — mixed', () => {
+ test('wikilink, markdown link, autolink in one string', () => {
+ const input = '[[A]] then [B](./b.md) and https://c.example';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs.map((s) => s.type)).toEqual(['wikilink', 'text', 'link', 'text', 'autolink']);
+ expectRoundTrip(input, segs);
+ });
+
+ test('plain text only', () => {
+ const input = 'no links here, just words';
+ const segs = tokenizePropertyInlineLinks(input);
+ expect(segs).toEqual([{ type: 'text', value: 'no links here, just words' }]);
+ });
+
+ test('empty string', () => {
+ expect(tokenizePropertyInlineLinks('')).toEqual([]);
+ });
+});
+
+describe('hasInlineLinks', () => {
+ test('returns false for plain text', () => {
+ expect(hasInlineLinks('plain words')).toBe(false);
+ });
+
+ test('returns false for empty string', () => {
+ expect(hasInlineLinks('')).toBe(false);
+ });
+
+ test('returns true for wikilink', () => {
+ expect(hasInlineLinks('[[Page]] text')).toBe(true);
+ });
+
+ test('returns true for markdown link', () => {
+ expect(hasInlineLinks('[text](url)')).toBe(true);
+ });
+
+ test('returns true for bare URL', () => {
+ expect(hasInlineLinks('see https://example.com')).toBe(true);
+ });
+
+ test('cheap-probe short-circuit: text containing `[[` but no real wikilink → still calls tokenizer', () => {
+ expect(hasInlineLinks('value with [[]] sequence')).toBe(false);
+ });
+});
diff --git a/packages/app/src/components/property-inline-link-tokens.ts b/packages/app/src/components/property-inline-link-tokens.ts
new file mode 100644
index 000000000..c1d506a3a
--- /dev/null
+++ b/packages/app/src/components/property-inline-link-tokens.ts
@@ -0,0 +1,110 @@
+import { parseWikiLink } from '@inkeep/open-knowledge-core';
+
+export type PropertyInlineSegment =
+ | { type: 'text'; value: string }
+ | {
+ type: 'wikilink';
+ raw: string;
+ target: string;
+ alias: string | null;
+ anchor: string | null;
+ }
+ | { type: 'link'; raw: string; text: string; url: string }
+ | { type: 'autolink'; raw: string; url: string };
+
+function parseMarkdownLink(src: string): { raw: string; text: string; url: string } | null {
+ if (src[0] !== '[') return null;
+ let i = 1;
+ let textEnd = -1;
+ while (i < src.length) {
+ const ch = src[i];
+ if (ch === ']') {
+ textEnd = i;
+ break;
+ }
+ if (ch === '[') return null;
+ i++;
+ }
+ if (textEnd < 0) return null;
+ if (src[textEnd + 1] !== '(') return null;
+ const urlStart = textEnd + 2;
+ const urlEnd = src.indexOf(')', urlStart);
+ if (urlEnd < 0) return null;
+ const text = src.slice(1, textEnd);
+ const url = src.slice(urlStart, urlEnd).trim();
+ if (!url) return null;
+ return { raw: src.slice(0, urlEnd + 1), text, url };
+}
+
+const AUTOLINK_RE = /^https?:\/\/[^\s<>"'`]+/i;
+const TRAILING_PUNCT_RE = /[.,;:!?]+$/;
+
+function parseAutolink(src: string): { raw: string; url: string } | null {
+ const match = AUTOLINK_RE.exec(src);
+ if (!match) return null;
+ let url = match[0];
+ if (url.endsWith(')') && !url.slice(0, -1).includes('(')) {
+ url = url.slice(0, -1);
+ }
+ url = url.replace(TRAILING_PUNCT_RE, '');
+ if (!url) return null;
+ return { raw: url, url };
+}
+
+export function tokenizePropertyInlineLinks(text: string): PropertyInlineSegment[] {
+ const out: PropertyInlineSegment[] = [];
+ let i = 0;
+ let plainStart = 0;
+
+ function flushPlain(end: number): void {
+ if (end > plainStart) out.push({ type: 'text', value: text.slice(plainStart, end) });
+ }
+
+ while (i < text.length) {
+ if (text[i] === '[' && text[i + 1] === '[') {
+ const wiki = parseWikiLink(text.slice(i));
+ if (wiki) {
+ flushPlain(i);
+ out.push({
+ type: 'wikilink',
+ raw: wiki.raw,
+ target: wiki.target,
+ alias: wiki.alias,
+ anchor: wiki.anchor,
+ });
+ i += wiki.raw.length;
+ plainStart = i;
+ continue;
+ }
+ }
+ if (text[i] === '[') {
+ const md = parseMarkdownLink(text.slice(i));
+ if (md) {
+ flushPlain(i);
+ out.push({ type: 'link', raw: md.raw, text: md.text, url: md.url });
+ i += md.raw.length;
+ plainStart = i;
+ continue;
+ }
+ }
+ if ((text[i] === 'h' || text[i] === 'H') && /^https?:\/\//i.test(text.slice(i, i + 8))) {
+ const auto = parseAutolink(text.slice(i));
+ if (auto) {
+ flushPlain(i);
+ out.push({ type: 'autolink', raw: auto.raw, url: auto.url });
+ i += auto.raw.length;
+ plainStart = i;
+ continue;
+ }
+ }
+ i++;
+ }
+ flushPlain(text.length);
+ return out;
+}
+
+export function hasInlineLinks(text: string): boolean {
+ if (!text) return false;
+ if (!text.includes('[[') && !text.includes('](') && !/https?:\/\//i.test(text)) return false;
+ return tokenizePropertyInlineLinks(text).some((seg) => seg.type !== 'text');
+}