]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
fix: added a normalization step for MathJax-style \[\] and \(\) delimiters (#16599)
authorPascal <redacted>
Thu, 16 Oct 2025 14:28:41 +0000 (16:28 +0200)
committerGitHub <redacted>
Thu, 16 Oct 2025 14:28:41 +0000 (16:28 +0200)
* fix: added a normalization step for MathJax-style \[\] and \(\) delimiters

So inline and block equations are converted before KaTeX rendering,
enabling proper display of model-generated LaTeX in the WebUI

* chore: update webui build output

tools/server/public/index.html.gz
tools/server/webui/src/lib/components/app/misc/MarkdownContent.svelte

index 1c62ebe9686057df8254804a8862f2d1eed8db1c..34818012c8e4609a8879c636008bb8d0670bc81a 100644 (file)
Binary files a/tools/server/public/index.html.gz and b/tools/server/public/index.html.gz differ
index 24d29c2b3e51eca0a53bfb46c6737353e1e0af8e..1f4caa9003bceaae72ab86743ea9877601f86650 100644 (file)
                return mutated ? tempDiv.innerHTML : html;
        }
 
+       function normalizeMathDelimiters(text: string): string {
+               return text
+                       .replace(/(^|[^\\])\\\[((?:\\.|[\s\S])*?)\\\]/g, (_, prefix: string, content: string) => {
+                               return `${prefix}$$${content}$$`;
+                       })
+                       .replace(/(^|[^\\])\\\(((?:\\.|[\s\S])*?)\\\)/g, (_, prefix: string, content: string) => {
+                               return `${prefix}$${content}$`;
+                       });
+       }
+
        async function processMarkdown(text: string): Promise<string> {
                try {
-                       const result = await processor().process(text);
+                       const normalized = normalizeMathDelimiters(text);
+                       const result = await processor().process(normalized);
                        const html = String(result);
                        const enhancedLinks = enhanceLinks(html);