Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken paths #34

Open
danielcobo opened this issue Dec 23, 2018 · 2 comments
Open

Broken paths #34

danielcobo opened this issue Dec 23, 2018 · 2 comments

Comments

@danielcobo
Copy link

This
<script type="text/javascript" src="./node_modules/mathjax-electron/resources/MathJax/MathJax.js?config=electron"></script>
should be
<script type="text/javascript" src="./node_modules/mathjax-electron/MathJax-2.7.5/MathJax.js"></script>

However even after that fix, I get the error:
MathJax.js:19 GET ./node_modules/mathjax-electron/MathJax-2.7.5/extensions/MathMenu.js?V=2.7.5 net::ERR_FILE_NOT_FOUND

Are the paths broken or can someone throw together an actual working demo of this thing?

@rgbkrk
Copy link
Member

rgbkrk commented Dec 28, 2018

Hmmm, I've been using this with an electron app, and we don't use the script tag approach. We rely on mathJaxPath from mathjax-electron:
https://github.com/nteract/nteract/blob/72a942e690f85e2f05a80a764909cf3b9f1fd872/applications/desktop/src/notebook/index.js#L7

Then it gets passed into our script loader https://github.com/nteract/nteract/blob/f97dfb72ab98385c06af859385215d6904a1e552/packages/mathjax/src/provider.tsx#L70, which does end up injecting a script tag on the page.

@kkiwo12
Copy link

kkiwo12 commented Jan 26, 2021

For anyone still stuck on this error, here is what I did:

I loaded the index.js file on the <head> of the HTML document and not the script indicated on the documentation.
My <head> now looks like this:

<head>
  <meta charset="UTF-8">
  <title>Mathjax</title>
  <!--  provide the path to your node_modules folder. -->
  <script src="../../node_modules/mathjax-electron/index.js"></script>
</head>

On a <script> code block or on a separate js file, I loaded the mathJaxHelper like so:
let mathjaxHelper = require('mathjax-electron');

I then loaded MathJax manually, using loadMathJax(). I passed the document and a callback on this method.
On the callback, this is where I run my MathJax methods. This approach seems to be working for me.

Sample code, loaded on the same HTML file:

<script>
    var mathjaxHelper = require('mathjax-electron');
    //  I load the mathjax manually, using loadMathJax().
    //  Inside the loadMathJax callback, I do my mathjax stuff
    mathjaxHelper.loadMathJax(document, () => {
      console.log('loaded');
      var container = document.createElement('div');
      container.innerHTML = '$$\\sum\\limits_{i=0}^{\\infty} \\frac{1}{n^2}$$';
      //  This works now!
      mathjaxHelper.typesetMath(container);
      document.querySelector('body').append(container);
    });
</script>

Hope this helps anyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants