Unverified Commit 9600fbb6 authored by Kada Liao's avatar Kada Liao Committed by GitHub

fix: multiple inline latex parsing (#2214)

parent 04595a5f
import TeX from "@matejmazur/react-katex";
import "katex/dist/katex.min.css";
export const LATEX_INLINE_REG = /\$(.+?)\$|\\\(([^\\]+)\\\)/g;
export const LATEX_INLINE_REG = /\$(.+?)\$|\\\((.+?)\\\)/;
const inlineRenderer = (rawStr: string) => {
const matchResult = LATEX_INLINE_REG.exec(rawStr);
if (!matchResult) {
return rawStr;
if (matchResult) {
let latexCode = "";
if (matchResult[1]) {
latexCode = matchResult[1];
} else if (matchResult[2]) {
latexCode = matchResult[2];
}
return <TeX key={latexCode}>{latexCode}</TeX>;
}
let latexCode = "";
if (matchResult[1]) {
// $
latexCode = matchResult[1];
} else if (matchResult[2]) {
// \( and \)
latexCode = matchResult[2];
}
return <TeX>{latexCode}</TeX>;
return rawStr;
};
export default {
......
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