diff --git a/examples/server/public/index.html.gz b/examples/server/public/index.html.gz
index f15e8825f..cd977cf1a 100644
Binary files a/examples/server/public/index.html.gz and b/examples/server/public/index.html.gz differ
diff --git a/examples/server/webui/src/components/MarkdownDisplay.tsx b/examples/server/webui/src/components/MarkdownDisplay.tsx
index c71fbca03..5ec9731e9 100644
--- a/examples/server/webui/src/components/MarkdownDisplay.tsx
+++ b/examples/server/webui/src/components/MarkdownDisplay.tsx
@@ -135,6 +135,8 @@ export function preprocessLaTeX(content: string): string {
// Step 2: Protect existing LaTeX expressions
const latexExpressions: string[] = [];
+
+ // Protect block math ($$...$$), \[...\], and \(...\) as before.
content = content.replace(
/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\(.*?\\\))/g,
(match) => {
@@ -143,7 +145,22 @@ export function preprocessLaTeX(content: string): string {
}
);
- // Step 3: Escape dollar signs that are likely currency indicators
+ // Protect inline math ($...$) only if it does NOT match a currency pattern.
+ // We assume a currency pattern is one where the inner content is purely numeric (with optional decimals).
+ content = content.replace(/\$([^$]+)\$/g, (match, inner) => {
+ if (/^\s*\d+(?:\.\d+)?\s*$/.test(inner)) {
+ // This looks like a currency value (e.g. "$123" or "$12.34"),
+ // so don't protect it.
+ return match;
+ } else {
+ // Otherwise, treat it as a LaTeX expression.
+ latexExpressions.push(match);
+ return `<>`;
+ }
+ });
+
+ // Step 3: Escape dollar signs that are likely currency indicators.
+ // (Now that inline math is protected, this will only escape dollars not already protected)
content = content.replace(/\$(?=\d)/g, '\\$');
// Step 4: Restore LaTeX expressions