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

Math formulas are not rendered #283

Closed
mazen-mardini opened this issue Mar 29, 2023 · 9 comments · Fixed by #323
Closed

Math formulas are not rendered #283

mazen-mardini opened this issue Mar 29, 2023 · 9 comments · Fixed by #323
Assignees
Labels
Milestone

Comments

@mazen-mardini
Copy link

mazen-mardini commented Mar 29, 2023

Hello!

Math formulas in for example (Theoretical) Computer Science are not rendered. Normally, MathJax should render an expression such as $a \in R$ to a ∈ R, but it doesn't.

I suspect that this affects all StackOverflow packages.

@kelson42
Copy link
Contributor

kelson42 commented Mar 29, 2023

@kelson42 kelson42 added the bug label Mar 29, 2023
@kelson42 kelson42 added this to the 2.1.0 milestone Mar 29, 2023
@mazen-mardini
Copy link
Author

@rgaudin Something else worth noting from your example, is that the embedded image seems to be incorrect as well.

This applies to the earlier version of the question, which the ZIM is based on: https://mathoverflow.net/posts/227713/revisions

@rgaudin
Copy link
Member

rgaudin commented Mar 30, 2023

@mazen-mardini thank you for noticing! I've opened a separate ticket.

@stale
Copy link

stale bot commented May 29, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label May 29, 2023
@kelson42 kelson42 pinned this issue Oct 29, 2023
@stale stale bot removed the stale label Oct 29, 2023
@benoit74 benoit74 modified the milestones: 2.1.0, 2.2.0 Mar 27, 2024
@kelson42 kelson42 modified the milestones: 3.0.0, 2.2.0 May 18, 2024
@Jaifroid
Copy link

Reddit users are complaining about this here: https://www.reddit.com/r/Kiwix/comments/1g5q59l/how_to_render_latexmathjax_on_kiwix/

@kelson42
Copy link
Contributor

New complain here kiwix/kiwix-desktop#1225

To me, this is priority now to fux this. Too many people are impacted.

@benoit74
Copy link
Collaborator

It looks like the problem is mostly simple: MathJax configuration is not done properly, so only default MathJax configuration is applied.

Currently, configuring MathJax is based on a src attribute (see

<script src="{{ to_root }}static/js/MathJax.js?config=TeX-AMS_HTML-full"></script>
) where configuration must be inline according to the documentation (https://docs.mathjax.org/en/v2.0-latest/configuration.html).

This means that we do not enable the $...$ TeX syntax which is disabled by default (https://docs.mathjax.org/en/stable/tex.html).

I hacked the sample webpage on my browser and it works well (all equations are handled by MathJax).

Hacks (not sure all actions are required, I'm too lazy to confirm) are as follow:

Set the configuration inline instead of in an src (simply modify the DOM in inspector).

Remove existing MathJax script tag sourcing ../../static/js/MathJax.js?config=TeX-AMS_HTML-full (simply modify the DOM in inspector).

Cleanup MathJax (in debugger):

delete MathJax 

Add MathJax back:

const newScript = document.createElement('script')
newScript.src = '../../static/js/MathJax.js?config=TeX-AMS_HTML-full' 
document.head.appendChild(script2) 

Et voilà.

This now has to be incorporated in the codebase and tested in a real ZIM.

I'm not that experienced with sotoki, is there a possibility to test a modification without running the full scrape? Or should I just "zimrecreate" the ZIM with one or two modified HTML to confirm the solution? Or I'm maybe just overengineering the thing, it is supposed to take only 1 or 2 hours to run mathoverflow after all.

@rgaudin
Copy link
Member

rgaudin commented Oct 23, 2024

Shouldn't be that long. You can push a dev tag to try in ZF if you don't want to invest in this just for this issue which seems like a quick fix

@benoit74 benoit74 modified the milestones: 2.2.0, 2.1.3 Oct 29, 2024
@kelson42 kelson42 unpinned this issue Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants