mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-27 08:21:30 +00:00
fix: added a normalization step for MathJax-style \[\] and \(\) delimiters (#16599)
* 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
This commit is contained in:
Binary file not shown.
@@ -154,9 +154,20 @@
|
|||||||
return mutated ? tempDiv.innerHTML : html;
|
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> {
|
async function processMarkdown(text: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const result = await processor().process(text);
|
const normalized = normalizeMathDelimiters(text);
|
||||||
|
const result = await processor().process(normalized);
|
||||||
const html = String(result);
|
const html = String(result);
|
||||||
const enhancedLinks = enhanceLinks(html);
|
const enhancedLinks = enhanceLinks(html);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user