From ecf7b93f3fb41af7281ab0d4af494d838bfcddc3 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Fri, 20 Feb 2026 12:21:12 -0800 Subject: [PATCH] Add OSC 8 terminal hyperlink rendering for markdown links --- src/markdown.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/markdown.ts b/src/markdown.ts index 064d22f..69e0425 100644 --- a/src/markdown.ts +++ b/src/markdown.ts @@ -24,6 +24,12 @@ export function renderMarkdown(text: string): string { // Italic: *text* result = result.replace(/\*(.+?)\*/g, "\x1b[3m$1\x1b[23m") + // Links: [text](url) → OSC 8 terminal hyperlink, underlined blue + result = result.replace(/(? { + const url = href.replace(/\s+"[^"]*"$/, "") // strip optional title + return `\x1b]8;;${url}\x07\x1b[4;38;5;75m${text}\x1b[24;39m\x1b]8;;\x07` + }) + // Restore code spans as light blue result = result.replace(/\x00CODE(\d+)\x00/g, (_, i) => { return `\x1b[38;5;147m${codeSpans[parseInt(i)]}\x1b[39m`