From 03a28b25a0969b18100f97a1e38aa489556add38 Mon Sep 17 00:00:00 2001 From: calycekr <4094424+calycekr@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:53:00 +0900 Subject: [PATCH] feat: add KaTeX support for block and inline math rendering in Markdown (#1643) * feat: add KaTeX support for block and inline math rendering in Markdown * fix: Reintroduce escapeHTML to prevent raw HTML injection - Properly escape user-generated HTML to avoid DOM injection vulnerabilities. - Ensures KaTeX rendering remains unaffected while blocking malicious content. * feat: add KaTeX mhchem extension to enable KaTeX the \ce and \pu functions from the mhchem package. - https://github.com/KaTeX/KaTeX/tree/main/contrib/mhchem --------- Co-authored-by: Nathan Sarrazin --- .../components/chat/MarkdownRenderer.svelte | 188 +++++++++++++----- 1 file changed, 135 insertions(+), 53 deletions(-) diff --git a/src/lib/components/chat/MarkdownRenderer.svelte b/src/lib/components/chat/MarkdownRenderer.svelte index ecee2010d4c..975adaf3734 100644 --- a/src/lib/components/chat/MarkdownRenderer.svelte +++ b/src/lib/components/chat/MarkdownRenderer.svelte @@ -1,13 +1,144 @@