diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index f1693a94f..15a0501a3 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -80,6 +80,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(/^ { .replace(/<$/, '') .replaceAll(/<\|[a-z]+\|>/g, ' ') .replaceAll('<', '<') + .replaceAll('>', '>') .trim(); }; export const revertSanitizedResponseContent = (content: string) => { - return content.replaceAll('<', '<'); + return content + .replaceAll('<', '<') + .replaceAll('>', '>'); }; export const capitalizeFirstLetter = (string) => {