Skip to content

EPUB: Render TeX with MathJax #154

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

Merged
merged 2 commits into from
May 6, 2025
Merged

Conversation

AbeJellinek
Copy link
Member

Example EPUB: https://www.core-econ.org/wp-content/uploads/2024/10/the-economy-2-0-microeconomics-epub.epub

MathJax is a big library (it doubles the size of reader.js when imported statically), so we import it dynamically when a book actually needs it. Other than that, everything we're doing here is pretty straightforward. There's a new context menu item (Copy TeX) that will need its string copied over to the client.

https://forums.zotero.org/discussion/121716/epub-tex-not-typeset

@AbeJellinek AbeJellinek requested a review from mrtcode February 12, 2025 19:41
@mrtcode
Copy link
Member

mrtcode commented Feb 24, 2025

It works as expected. It’s a bit painful to add an extra 2.5 MB (less than 700 KB after compressing) to Zotero just to render formulas in some EPUBs, but that’s the cost of supporting EPUBs.

Anyway, looks good.

@AbeJellinek
Copy link
Member Author

Yeah, it is a little painful. It would be better if we could use KaTeX - since the note editor already uses that, it would gzip down to ~nothing in the final build - but MathJax seems like the de facto standard for EPUBs. I'll see if there's anything we can do to trim it down.

@AbeJellinek
Copy link
Member Author

OK, fonts are now loaded on demand and stored as WOFF. Not much of a size improvement, but I think this is as small as it's going to get.

@AbeJellinek AbeJellinek merged commit 371d4e7 into zotero:master May 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants