From 3a1fbb936b1f7d073f6762edaa036ac42722c2e7 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 11 May 2024 00:32:29 -0400 Subject: [PATCH] Always open links in a new tab --- src/lib/components/chat/Messages/ResponseMessage.svelte | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 5b228a9ff..1ad252f63 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -78,6 +78,13 @@ return `${code.replaceAll('&', '&')}`; }; + // Open all links in a new tab/window (from https://github.com/markedjs/marked/issues/655#issuecomment-383226346) + const origLinkRenderer = renderer.link; + renderer.link = (href, title, text) => { + const html = origLinkRenderer.call(renderer, href, title, text); + return html.replace(/^