Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified tools/server/public/index.html.gz
Binary file not shown.
9 changes: 4 additions & 5 deletions tools/server/webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/server/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
},
"dependencies": {
"highlight.js": "^11.11.1",
"katex": "^0.16.23",
"mode-watcher": "^1.1.0",
"pdfjs-dist": "^5.4.54",
"rehype-highlight": "^7.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@
return tempDiv.innerHTML;
}

function preprocessLatexDelimiters(text: string): string {
// Handle escaped bracket delimiters \[...\]
text = text.replace(/\\\[([\s\S]*?)\\\]/g, (match, content) => `$$${content}$$`);

// Handle standalone bracket delimiters [...]
text = text.replace(
/(^|\n)\s*\[\s*([\s\S]*?)\s*\](\s*(?:\n|$))/gm,
(match, prefix, content, suffix) => {
const mathSymbols = /[=+\-*/^_{}\\()αβγδεζηθικλμνξοπρστυφχψω∑∫∂∇±×÷≤≥≠≈∞]/;

if (mathSymbols.test(content)) {
return `${prefix}$$${content}$$${suffix}`;
}

return match;
}
);

return text;
}

function enhanceCodeBlocks(html: string): string {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = html;
Expand Down Expand Up @@ -132,7 +153,10 @@

async function processMarkdown(text: string): Promise<string> {
try {
const result = await processor().process(text);
// Preprocess LaTeX-style bracket delimiters before markdown processing
const preprocessedText = preprocessLatexDelimiters(text);

const result = await processor().process(preprocessedText);
const html = String(result);
const enhancedLinks = enhanceLinks(html);

Expand Down