Spaces:
Sleeping
Sleeping
Update static/index.html
Browse files- static/index.html +13 -3
static/index.html
CHANGED
|
@@ -229,6 +229,17 @@
|
|
| 229 |
|
| 230 |
|
| 231 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
document.addEventListener('DOMContentLoaded', () => {
|
| 233 |
// WebSocket connection management
|
| 234 |
let socket = null;
|
|
@@ -263,16 +274,15 @@
|
|
| 263 |
if (data.chunk) {
|
| 264 |
|
| 265 |
resultContent.innerHTML += data.chunk;
|
| 266 |
-
|
| 267 |
|
| 268 |
|
| 269 |
}
|
| 270 |
|
| 271 |
if (data.complete) {
|
| 272 |
const htmlChunk = marked.parse(resultContent.innerHTML);
|
| 273 |
-
|
| 274 |
// Append streaming chunks as HTML
|
| 275 |
-
resultContent.innerHTML =
|
| 276 |
|
| 277 |
renderMathInElement(resultContent, {
|
| 278 |
delimiters: [
|
|
|
|
| 229 |
|
| 230 |
|
| 231 |
<script>
|
| 232 |
+
|
| 233 |
+
function preprocessLatex(text) {
|
| 234 |
+
// Convert block math `[ ... ]` to `\[ ... \]`
|
| 235 |
+
text = text.replace(/\[([^\[\]]+)\]/g, '\\[$1\\]');
|
| 236 |
+
|
| 237 |
+
// Convert inline math `( ... )` to `\( ... \)`
|
| 238 |
+
text = text.replace(/\(([^\(\)]+)\)/g, '\\($1\\)');
|
| 239 |
+
|
| 240 |
+
return text;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
document.addEventListener('DOMContentLoaded', () => {
|
| 244 |
// WebSocket connection management
|
| 245 |
let socket = null;
|
|
|
|
| 274 |
if (data.chunk) {
|
| 275 |
|
| 276 |
resultContent.innerHTML += data.chunk;
|
|
|
|
| 277 |
|
| 278 |
|
| 279 |
}
|
| 280 |
|
| 281 |
if (data.complete) {
|
| 282 |
const htmlChunk = marked.parse(resultContent.innerHTML);
|
| 283 |
+
const preProcLatex=preprocessLatex(htmlChunk);
|
| 284 |
// Append streaming chunks as HTML
|
| 285 |
+
resultContent.innerHTML = preProcLatex;
|
| 286 |
|
| 287 |
renderMathInElement(resultContent, {
|
| 288 |
delimiters: [
|