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

Use locally installed MathJax package when available #675

Open
cameel opened this issue Feb 5, 2023 · 5 comments
Open

Use locally installed MathJax package when available #675

cameel opened this issue Feb 5, 2023 · 5 comments
Labels

Comments

@cameel
Copy link

cameel commented Feb 5, 2023

I recently noticed that on my machine rednotebook tries to connect to cdn.jsdelivr.net every time it starts. Apparently to download mathjax.

This seems wasteful and will make math rendering impossible without an Internet connection in an application that otherwise is perfectly usable offline. Some distributions, like Arch Linux ship a mathjax package in their official repositories. Would it be possible to make rednotebook use that when available and only if not fall back to downloading it? Even better would be a setup.py flag to make rednotebook always use a local installation at a given path and never download anything.

I found this #264 (comment), which says that the reason for not using a local copy was a concern about the package size. It seems that relying on distros to provide it would be a perfect solution here.

@cameel cameel added the wishlist label Feb 5, 2023
@jendrikseipp
Copy link
Owner

Allowing to use a local MathJax copy via distro packages is a nice idea and I'm happy to review a PR for this. Some things to keep in mind while working on this issue:

  • The code needs a list of paths where the MathJax files are put by the most common distros.
  • The changelog needs a note for packagers which informs them about this list.
  • Journals exported to HTML should always use remote MathJax to allow moving the HTML file between computers.

@cameel
Copy link
Author

cameel commented Feb 13, 2023

The code needs a list of paths where the MathJax files are put by the most common distros.

I did some initial research into that. Here's what I found in some common distros:

Distro Package Version Installation path tex-svg.js location
Arch Linux mathjax 3.2.2 /usr/share/mathjax/ tex-svg.js
Ubuntu libjs-mathjax in Lunar 2.7.9 /usr/share/javascript/mathjax/ missing
Debian libjs-mathjax in Sid 2.7.9 /usr/share/javascript/mathjax/ missing
Fedora mathjax 2.7.4 /usr/share/javascript/mathjax/ missing
OpenSUSE mathjax in Factory 2.6.0 /usr/share/javascript/mathjax/ missing

So, looks like there's a problem. Many distros still ship Mathjax 2.x. Perhaps it has something equivalent to tex-svg.js (I see a file called TeX-AMS_SVG.js for example) but I guess it might not be fully compatible.

In that case I think if would be best if it was possible to just specify the location of tex-svg.js during rednotebook setup and not try to detect it. Then the packager could use it if available in the distro and if not, maybe even download and include just that one file (depending on how strict the distro is on that). For my own use case, this would be enough (since I'm on Arch Linux anyway) and it would still be flexible enough to accommodate other cases.

@jendrikseipp
Copy link
Owner

Thanks for doing the research! Your proposed solution could work, but I have my doubt that it will be used by lots of people and it has the drawback that we need to test two different MathJax modes: online and offline.

Maybe we should think about bundling it again. How much space would a bundled MathJax need? How about the competitor KaTex? Are they both equally easy to bundle? Also, which of them can be fully embedded into journals exported as HTML?

@cameel
Copy link
Author

cameel commented Feb 13, 2023

I have my doubt that it will be used by lots of people and it has the drawback that we need to test two different MathJax modes: online and offline.

Yeah, you're probably right on that. I think Arch might adopt it for the official package if asked to but other distros would very likely ignore it or be at least reluctant. Not even saying anything about other platforms.

How much space would a bundled MathJax need?

On my system the whole mathjax package is 23 MB. But tex-svg.js on its own is 2 MB.

Maybe we should think about bundling it again.

If not at setup time then I think this would be my preferred solution.

But just wanted to note that you could also cache in user's home dir after the first download. It would be worse for me because rednotebook would still have to hit the servers at least once but IMO better than nothing.

How about the competitor KaTex? Are they both equally easy to bundle? Also, which of them can be fully embedded into journals exported as HTML?

I don't know the answers right away but, if that seems like a better solution to you, I could check when I have a bit of time.

@jendrikseipp
Copy link
Owner

It's probably wise to do this small research before deciding on a solution, yes. Of course this is not urgent.

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

No branches or pull requests

2 participants