Skip to content
This repository has been archived by the owner on Aug 28, 2017. It is now read-only.

Use MathJax for LaTeX rendering #17

Merged
merged 2 commits into from
Apr 14, 2016
Merged

Use MathJax for LaTeX rendering #17

merged 2 commits into from
Apr 14, 2016

Conversation

lgeiger
Copy link
Member

@lgeiger lgeiger commented Apr 10, 2016

Include a slimed down version of MathJax similar to preview-inline as proposed by @mangecoeur in #99

The file size is 3 MB in total (mainly the font).

I tested it with hydrogen and it works great:
latex

@lgeiger
Copy link
Member Author

lgeiger commented Apr 11, 2016

I rebased it, because the diff is to large to display ;)
The relevant changes are in this commit.

@minrk
Copy link
Contributor

minrk commented Apr 11, 2016

Should mathjax be included, and not a dependency?

@mangecoeur
Copy link

@minrk Including is better because it's easier to include only what's needed (I explored both for preview-inline). There aren't really any packages on npm or bower which would fit - any 'general purpose' package would by definition include things which aren't needed - and a full MathJax install is a beast because they support many browsers and configurations. Even the subset that jupyter/ipython use is pretty heavy. You go from a 35MB install for the full MathJax, to about 12MB for a semi-slim one like ipython use, to about 3MB when you only need to support Atom/Electron (and i suspect it could be even less with a better understanding of font requirements).

@minrk
Copy link
Contributor

minrk commented Apr 11, 2016

Gotcha. It might be worthwhile to make that a package, anyway, even within the nteract org: mathjax-electron, etc.

@mangecoeur
Copy link

I guess that could work, assuming it doesn't add too much administrative overhead. Could be a package or a git submodule.

@rgbkrk
Copy link
Member

rgbkrk commented Apr 11, 2016

It might be worthwhile to make that a package, anyway, even within the nteract org: mathjax-electron, etc.

This sounds like a great idea, what do you think @lgeiger? I'd use it outside of classic transformime as well (while still in an electron context).

I guess that could work, assuming it doesn't add too much administrative overhead. Could be a package or a git submodule.

We'll find that out fairly quickly!

@lgeiger
Copy link
Member Author

lgeiger commented Apr 11, 2016

This sounds like a great idea!

I'm a bit busy at the moment so it may take a while, but I'll give it a try this evening.

@rgbkrk
Copy link
Member

rgbkrk commented Apr 11, 2016

It can be exactly what you have in here as well, including mathjax-helper.js

@lgeiger
Copy link
Member Author

lgeiger commented Apr 11, 2016

OK I made a new package: mathjax-electron

@lgeiger
Copy link
Member Author

lgeiger commented Apr 11, 2016

I couldn't figure out how to unittest the SVG from MathJax. Is there a possibility to do this?

@mangecoeur
Copy link

I was able to do some testing in preview-inline using Atom's testing framework since that gives you access to a DOM page for testing. Basically just test that an element is rendered (i.e. exists after the call). No idea how this works in bare Electron. I think it's reasonable to assume MathJax Just Works since they have their own test suite.

@rgbkrk
Copy link
Member

rgbkrk commented Apr 12, 2016

You may want to work with electron-mocha, that's what we use on nteract/nteract and a few other packages instead of JSDom. Works quite well as a drop-in replacement for mocha and it can run in the renderer process by using --renderer as one of the args.

@lgeiger
Copy link
Member Author

lgeiger commented Apr 14, 2016

Maybe I'll try electron-mocha in the future. But for now I agree with @mangecoeur.
I think it's reasonable to assume MathJax works, so testing for the existence of the MathJax script is enough.

@rgbkrk
Copy link
Member

rgbkrk commented Apr 14, 2016

Now that the phosphor folks have fully divested from transformime, I think it's reasonable for us to go ahead with this even though it says Electron on the tin (it's more "chrome-like" than Electron I suppose).

container.type = 'math/tex';
container.innerHTML = value.replace('<br>', '');

mathjaxHelper.loadMathJax(document);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this reload MathJax every time a LaTeXTransform is done?

Copy link
Member Author

@lgeiger lgeiger Apr 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgbkrk rgbkrk merged commit fff03aa into nteract:master Apr 14, 2016
@rgbkrk
Copy link
Member

rgbkrk commented Apr 14, 2016

Merging, let's keep iterating. Thank you for stellar work as always @lgeiger!

@lgeiger
Copy link
Member Author

lgeiger commented Apr 14, 2016

Oh I'm flattered 😄.

Should we do another minor release?

@rgbkrk
Copy link
Member

rgbkrk commented Apr 14, 2016

Sounds great to me.

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

Successfully merging this pull request may close these issues.

None yet

4 participants