2024-11-03 23:38:29 +05:30
|
|
|
export const preprocessLaTeX = (content: string) => {
|
2024-11-03 23:39:42 +05:30
|
|
|
// Replace block-level LaTeX delimiters \[ \] with $$ $$
|
|
|
|
|
|
|
|
|
|
const blockProcessedContent = content.replace(
|
|
|
|
|
/\\\[(.*?)\\\]/gs,
|
|
|
|
|
(_, equation) => `$$${equation}$$`
|
|
|
|
|
)
|
|
|
|
|
// Replace inline LaTeX delimiters \( \) with $ $
|
|
|
|
|
const inlineProcessedContent = blockProcessedContent.replace(
|
|
|
|
|
/\\\((.*?)\\\)/gs,
|
|
|
|
|
(_, equation) => `$${equation}$`
|
|
|
|
|
)
|
|
|
|
|
return inlineProcessedContent
|
|
|
|
|
}
|