"docs/source/Tutorial/WebUI.rst" did not exist on "f13a9222f1e6b21d1c342b44e1ae17178e550acc"
Commit 41fecb80 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

enh: latex

parent 52cf06b3
...@@ -182,6 +182,7 @@ ...@@ -182,6 +182,7 @@
{ left: '\\[', right: '\\]', display: false }, { left: '\\[', right: '\\]', display: false },
{ left: '[ ', right: ' ]', display: false }, { left: '[ ', right: ' ]', display: false },
{ left: '\\begin{equation}', right: '\\end{equation}', display: true }, { left: '\\begin{equation}', right: '\\end{equation}', display: true },
{ left: '\\begin{matrix}', right: '\\end{matrix}', display: true },
{ left: '\\begin{align}', right: '\\end{align}', display: true }, { left: '\\begin{align}', right: '\\end{align}', display: true },
{ left: '\\begin{alignat}', right: '\\end{alignat}', display: true }, { left: '\\begin{alignat}', right: '\\end{alignat}', display: true },
{ left: '\\begin{gather}', right: '\\end{gather}', display: true }, { left: '\\begin{gather}', right: '\\end{gather}', display: true },
......
...@@ -6,9 +6,29 @@ import { WEBUI_BASE_URL } from '$lib/constants'; ...@@ -6,9 +6,29 @@ import { WEBUI_BASE_URL } from '$lib/constants';
// Helper functions // Helper functions
////////////////////////// //////////////////////////
const convertLatexToSingleLine = (content) => {
// Patterns to match multiline LaTeX blocks
const patterns = [
/(\$\$[\s\S]*?\$\$)/g, // Match $$ ... $$
/(\\[\s\S]*?\\])/g, // Match \[ ... \]
/(\$\[\s\S]*?\$\])/g, // Match $\[ ... \]$
/(\$\(\s\S]*?\$\))/g, // Match $\( ... \)$
/(\\begin\{[a-z]+\}[\s\S]*?\\end\{[a-z]+\})/g // Match \begin{...} ... \end{...}
];
patterns.forEach((pattern) => {
content = content.replace(pattern, (match) => {
return match.replace(/\s+/g, ' ').trim();
});
});
return content;
};
export const sanitizeResponseContent = (content: string) => { export const sanitizeResponseContent = (content: string) => {
// replace single backslash with double backslash // replace single backslash with double backslash
content = content.replace(/\\/g, '\\\\'); content = content.replace(/\\/g, '\\\\');
content = convertLatexToSingleLine(content);
// First, temporarily replace valid <video> tags with a placeholder // First, temporarily replace valid <video> tags with a placeholder
const videoTagRegex = /<video\s+src="([^"]+)"\s+controls><\/video>/gi; const videoTagRegex = /<video\s+src="([^"]+)"\s+controls><\/video>/gi;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment