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

the tex2jax and jsMath2jax preprocessors interfere with each other #18

Closed
dpvc opened this issue Nov 9, 2010 · 4 comments
Closed

the tex2jax and jsMath2jax preprocessors interfere with each other #18

dpvc opened this issue Nov 9, 2010 · 4 comments
Labels

Comments

@dpvc
Copy link
Member

dpvc commented Nov 9, 2010

It looks like tex2jax and jsMath2jax can cause problems for each other. In particular, it looks like the preview for one can get translated by the other one (e.g., when the preview includes a LaTeX environment, which will look like math to be processed by the other one).

This needs to be looked into more carefully to see what is actually going on. It may be enough to check that the parent element is not of class MathJax_Preview.

See http://groups.google.com/group/mathjax-users/browse_thread/thread/40ba5ea8541d93cf/6394fd166c7c6c02?hl=en#6394fd166c7c6c02 for details.

Davide

@dpvc
Copy link
Member Author

dpvc commented Nov 9, 2010

It looks like there is more to it that that. If the tex2jax processor runs first, it will see \begin{xxx}...\end{xxx} that is in the <span class="math">...</span> and process it, then the jsMath2jax processor will take the innerHTML of the span (which now includes a preview and script tag) and make that into the text of a new script tag. So the preview and script from tex2jax becomes part of the typeset output of jsMath2jax.

Perhaps having jsMath2jax check if the contents already includes a math script and simply removing the span or div in that case would be sufficient.

Davide

@dpvc
Copy link
Member Author

dpvc commented Nov 9, 2010

The problem turned out to be what I said above: when tex2jax runs first, it processes the contents of the <span class="math"> if it contains a LaTeX environment (since those are processed without other math delimiters), adding a preview and math script inside the span. Then jsMath2jax turns the span into another math span, with its innerHTML as the content of the math. That turns the preview and script into text that becomes part of the math.

The solution is to prevent jsMath2tex from processing the contents of a span that already has a math script it in (presumably from tex2jax). This works because the span is not supposed to contain anything but text, so if there is a script in it, it is invalid anyway, so it should not be processed.

The issue of processing the previews turns out to not be a problem after all. The tex2jax preprocessor already skips tags with class containing MathJax (and so in particular, MathJax_Preview), so it will not reprocesses previews created by jsMath2jax if it runs first. On the other hand, if tex2jax runs first, \the previews will contain just the text of the mathematics, not any span's or divs of class math, so jsMath will not reprocess them.

The issue should be resolved by the change in the issue18 branch of my fork. See dpvc@6dd80fa for details.

Davide

@shogun70
Copy link
Contributor

Works for me. I've commited it.

@dpvc
Copy link
Member Author

dpvc commented Nov 11, 2010

Thanks.

This issue was closed.
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