Add OSC 8 terminal hyperlink rendering for markdown links
This commit is contained in:
parent
3c1f42e985
commit
ecf7b93f3f
|
|
@ -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(/(?<!!)\[([^\]]+)\]\(([^)]+)\)/g, (_, text, href) => {
|
||||
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`
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user