react-mathjax icon indicating copy to clipboard operation
react-mathjax copied to clipboard

Unable to render ascii unless I change scriptType in node.js file

Open himajasuman opened this issue 8 years ago • 2 comments

I am trying to render ascii math in my react component, const mathOptions = { AsciiMath: { useMathMLspacing: true }, tex2jax: { inlineMath: [ ['$', '$'], ['\\(', '\\)'] ] }, "HTML-CSS": { linebreaks: { automatic: true } }, extensions: ['asciimath2jax.js'], jax: ['input/TeX', 'input/AsciiMath', 'output/HTML-CSS'] }; const mathScript = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML"; const mathContent = 'sum_(i=1)\\^n i=(n(n+1))\/2'; itemMarkup = <MathJax.Context options={mathOptions} script={mathScript}> <MathJax.Node>{mathContent}</MathJax.Node> </MathJax.Context>; I am expecting it to render like screen shot 2017-07-15 at 2 27 09 pm but, it is rendering like screen shot 2017-07-15 at 2 30 42 pm

because, it is rendering like Tex, rather than ascii. If I change https://github.com/SamyPesse/react-mathjax/blob/master/src/node.js#L121 to this.script.type = 'math/asciimath; ' + (inline ? '' : 'mode=display'); it works.

is there a way I can pass that config.

Thanks for the wonderful library.

himajasuman avatar Jul 15 '17 21:07 himajasuman

@pyramation is there anything I could do to resolve this issue?

himajasuman avatar Jul 20 '17 21:07 himajasuman

Try this, (caveat, I don't use asciimath)

const defaultOptions = {
  showProcessingMessages: false,
  messageStyle: 'none',
  showMathMenu: false,
  tex2jax: {
    processEnvironments: true,
    inlineMath: [['$', '$'], ['\\(', '\\)']],
    displayMath: [['$$', '$$'], ['\\[', '\\]']],
    preview: 'none',
    processEscapes: true
  }
};

class App extends Component {
  render() {
    return (
      <Context options={defaultOptions}>
        <div>
$\sum_{i=1}^n i= \frac{n(n+1)}{2}$
        </div>
      </Context>
    );
  }
}

pyramation avatar Jul 24 '17 08:07 pyramation