simov / markdown-viewer

Markdown Viewer / Browser Extension
MIT License
1.06k stars 133 forks source link

MathJax problem #62

Closed izaakm closed 6 years ago

izaakm commented 6 years ago

This line wrecks markdown when MathJax is enabled:

        ()       \(\)      \(\)       \(\)      grouping into an atom

Removing one of the \(\) does not cause the problem. IE, the following renders correctly:

        ()       \(\)       \(\)      grouping into an atom

But the following does not render correctly:

        ()       \(\)      grouping into an atom

A little more context:

I have the above in some notes as a 'code'/verbatim block that I copy/pasted from vim :help magic:

Examples:
after:  \v       \m        \M         \V        match
              'magic'  'nomagic'
        $        $         $          \$        matches end-of-line
        .        .         \.         \.        matches any character
        *        *         \*         \*        any number of the previous atom
        ~        ~         \~         \~        latest substitute string
        ()       \(\)      \(\)       \(\)      grouping into an atom
        |        \|        \|         \|        separating alternatives
        \a       \a        \a         \a        alphabetic character
        \\       \\        \\         \\        literal backslash
        \.       \.        .          .         literal dot
        \{       {         {          {         literal '{'
        a        a         a          a         literal 'a'

I don't use mathjax when I'm looking at my vim notes file, but I do often need mathjax on other files. Switching mathjax on and off depending on the markdown file is kind of annoying. Unless of course I could enable in some settings to specify 'don't use mathjax on this file.'

I'm not sure if this is a general mathjax problem or specific to this extension.

simov commented 6 years ago

The bug is caused by the regex that I'm using in the background to find Mathjax blocks. I've managed to fix it, so now things like \(\) won't 'brake' the markdown rendering (at least in the next release).

However, the special Mathjax delimiters can't be used while the Mathjax option is enabled, unless they are wrapped inside inline or block code - documented here. So you need to wrap it up with:

vim output \(\) ...
```


or \`\\(\\)\` if it's inline. This is already implemented.

Currently there is no way to specify per file configuration, although I've been thinking about it in the past.

Let me know if anything of the above helps.
simov commented 6 years ago

@izaakm this was fixed in v3.6, at least the rendering won't brake on empty MathJax expressions. You can see what is currently supported by Markdown Viewer here or pull the repo locally and play around with the options.

Per-file configuration is up for consideration, but currently not implemented. You can open up separate issue for it if you want :+1: