Merge pull request #2180 from austenadler/dev

Always open links in chat in a new tab
This commit is contained in:
Timothy Jaeryang Baek 2024-05-25 21:32:39 -10:00 committed by GitHub
commit 6e89a481be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -80,6 +80,13 @@
return `<code>${code.replaceAll('&amp;', '&')}</code>`;
};
// 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(/^<a /, '<a target="_blank" rel="nofollow" ');
};
const { extensions, ...defaults } = marked.getDefaults() as marked.MarkedOptions & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
extensions: any;

View File

@ -12,11 +12,14 @@ export const sanitizeResponseContent = (content: string) => {
.replace(/<$/, '')
.replaceAll(/<\|[a-z]+\|>/g, ' ')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.trim();
};
export const revertSanitizedResponseContent = (content: string) => {
return content.replaceAll('&lt;', '<');
return content
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>');
};
export const capitalizeFirstLetter = (string) => {