From d0af1c9e63581b160f5d47497e73e034fa5c2e06 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 24 May 2020 12:41:57 -0700 Subject: fix symbol render bug + latex line break support --- frontend/src/components/renderers/Latex.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/renderers/Latex.js b/frontend/src/components/renderers/Latex.js index 7aacf7a..6915f75 100644 --- a/frontend/src/components/renderers/Latex.js +++ b/frontend/src/components/renderers/Latex.js @@ -10,8 +10,17 @@ const StyledInlineLatex = styled.div` class Latex extends React.Component { render() { - // split by line break chars (\\, \newline, \break) - const els = this.props.content.split(/\\\\|\\newline|\\break/) + // split by \begin{...} and \end{...} flags + const els = this.props.content.split(/(\\begin\{.*\}[\s\S]*?\\end\{.*\})/gm).map(line => { + // line doesnt start with \begin{...}, safe to split on \\ + if (!line.match(/^(\\begin\{.*\})/)) { + return line.split("\\\\") + } else { + return line + } + }).flat() + + console.log(els) // if <=1 lines, just render block if (els.length <= 1) { @@ -22,7 +31,7 @@ class Latex extends React.Component { ); } else { // new inline block for every line - const blocks = els.map(line => + const blocks = els.map(line => {line} -- cgit v1.2.3