mb21 / panwriter

Markdown editor with pandoc integration and paginated preview.
https://PanWriter.com
GNU General Public License v3.0
1.03k stars 49 forks source link

Preview doesn't show inline math `$rank_{x1}$` correctly #53

Closed braindevices closed 2 years ago

braindevices commented 3 years ago

version: master, on ubuntu 20.04

inline equation: $A_x$

inline equation: $rank_{x1}$

expect: Screenshot from 2021-03-23 23-54-24

actual result: Screenshot from 2021-03-23 23-53-28

mb21 commented 3 years ago

Thanks, PanWriter preview is using KaTeX to render math... I'll try to update the KaTeX version...

mb21 commented 3 years ago

Ah, actually the problem occurs only when this is the last thing on a line... appears to be an interaction between markdown-it-texmath and markdown-it-attrs.

var md = require('markdown-it')({});
md = md.use( require('markdown-it-attrs') ) // removing this line fixes it
md = md.use( require('markdown-it-texmath').use( require('katex') ) );
md.render('$rank_{x1}$');

inputting the above in node, outputs:

<p x1=""><eq><span class="katex-error" title="ParseError: KaTeX parse error: Expected group after &#x27;_&#x27; at position 5: rank_̲" style="color:#cc0000">rank_</span></eq></p>

We've had one or two other cases where markdown-it-attrs caused problems... so probably best to start digging there...

mb21 commented 2 years ago

(fixed via https://github.com/arve0/markdown-it-attrs/issues/115)