shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.47k stars 173 forks source link

Atom Mathjax different than VSCode #1385

Open jakubkovac opened 5 years ago

jakubkovac commented 5 years ago

When rendering a simple markdown with latex mathjax equation as html Simple reproducible example: $$\hat{f}(x) = \sum\limits_{i=1}^N \hat{\alpha_i}\; y_i\; K(x,x_i) + \hat{\beta_i}$$

VS-code produces:

<script type="text/x-mathjax-config">
          MathJax.Hub.Config({"extensions":["tex2jax.js"],"jax":["input/TeX","output/HTML-CSS"],"messageStyle":"none","tex2jax":{"processEnvironments":false,"processEscapes":true,"inlineMath":[["$","$"],["\\(","\\)"]],"displayMath":[["$$","$$"],["\\[","\\]"]]},"TeX":{"extensions":["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]},"HTML-CSS":{"availableFonts":["TeX"]}});
        </script>
        <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>

While Atom produces

 <script type="text/x-mathjax-config">
          MathJax.Hub.Config({"extensions":["tex2jax.js"],"jax":["input/TeX","output/HTML-CSS"],"messageStyle":"none","tex2jax":{"processEnvironments":false,"processEscapes":true,"inlineMath":[["$","$"],["\\(","\\)"]],"displayMath":[["$$","$$"],["\\[","\\]"]]},"TeX":{"extensions":["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]},"HTML-CSS":{"availableFonts":["TeX"],"imageFont":null},"root":"file:///C:/Users/jakub.kovac/.atom/packages/markdown-preview-enhanced/node_modules/@shd101wyy/mume/dependencies/mathjax"});
        </script>
        <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>

The last particular statement:

"root":"file:///C:/Users/jakub.kovac/.atom/packages/markdown-preview-enhanced/node_modules/@shd101wyy/mume/dependencies/mathjax"

Makes it not rendering correctly in Firefox. It works in chrome. VS-code works in both browsers.

jakubkovac commented 5 years ago

I tried this on my Linux system and it produces the same root statement, but it works on Linux with both browsers. Is there a specific reason why that statement has to be there for Atom?

shd101wyy commented 5 years ago

I guess it is caused by this line https://github.com/shd101wyy/mume/blob/1e52e93fba7bc6b6f76d467394a5d20e35bbf8a2/src/markdown-engine.ts#L452 I remembered I added root to config because without it MathJax in vscode will not work. Probably changing that line to the following will solve the issue.

if (isForVSCode) {
    mathJaxConfig["root"] = utility.addFileProtocol(
    ....

Unfortunately I am not able to do it now. I will be busy for a while :(

jakubkovac commented 5 years ago

Thanks a lot for this. I'd be more than happy to help you with a pull request but unfortunately I know nothing about package development for Atom/VSCode. In the meantime I'll use VSCode on the windows system.