Skip to content
This repository

MathJax too keen to convert TeX markup in Sphinx generated HTML #332

Closed
jonathanfine opened this Issue October 09, 2012 · 7 comments

4 participants

Jonathan Fine Davide P. Cervone Dmitry Shachnev Peter Krautzberger
Jonathan Fine

As subject, with this input and ouput.

Input: https://gist.github.com/3859850

Output: https://gist.github.com/3859864

MathJax processes the {problematic} environment, but I don't want it to (and according to the Sphinx docs, it should not, I believe).

I've tried changing setting, and have changed behaviour, but not to give what I want.

This might also be regarded as a Sphinx bug.

Davide P. Cervone
Collaborator

In the output file you link to, MathJax should process the \begin{problematic}...\end{problematic} block as the default for tex2jax is to process \begin...end pairs (and assume they produce display math equations). You can turn that off my setting the processEnvironments option to false in the tex2jax section of your configuration. That could be included in the file itself as in-line configuration if you wanted (but I don't know how to do that in Sphinx).

Note that this will disable all processing of \begin..\end pairs that aren't explicitly inside math delimiters, so if you use this approach, you might need to put $$ around some environments that would otherwise have been handled by MathJax directly.

Alternatively, you could put the environment inside <pre> or <code> tags, in which case MathJax will ignore it (not sure how this is handled in Sphinx, but I suspect that its verbatim modes use such tags). Or you could put it inside <div class="tex2jax_ignore">...</div> (again, you would have to know how to make that happen in Sphinx). You may also be able to define your own classes, and you could add them to the ignoreClass pattern in the tex2jax section of your configuration.

See the tex2jax options documentation for details of controlling that, and the configuration documentation for how to do in-line configuration.

Jonathan Fine

I would like Sphinx and MathJax to be set up so that they work with each other. Sphinx puts its math into HTML elements with a math class, as I recall. I'd like there to be a MathJax configuration option that recognizes as math exactly the things that Sphinx intends to be MathJax math. It's clearly an interface issue between Sphinx and MathJax.

Is it possible to configure MathJax by supplying a JavaScript function that returns the nodes that MathJax should be processing? This would be good, because then the Sphinx configuration for MathJax needs only to add this this function to its MathJax configuration.

I've added a Sphinx issue, with the same title: https://bitbucket.org/birkenfeld/sphinx/issue/1023/mathjax-too-keen-to-convert-tex-markup-in

Jonathan Fine jonathanfine closed this October 22, 2012
Jonathan Fine

Oops - did not mean to close the issue.

Jonathan Fine jonathanfine reopened this October 22, 2012
Dmitry Shachnev

@jonathanfine I had the same problem and was told how to do that in this discussion.

The easiest way is adding class="tex2jax_ignore" to your <body> and add this to MathJax config:

tex2jax: {
  processClass: "math"
}
Peter Krautzberger
Owner

@jonathanfine you could combine what @dpvc and @mitya57 wrote: set processEnvironments to false and specify the processClass. That should do the trick, giving you a Sphinx specific base configuration.

Davide P. Cervone
Collaborator

I don't think you need to set processEnvironments to false if you use @mitya57's suggestions.

On the other hand, if inline math is in <span class="math">...</span> and display math is in <div class="math">...</div>, then you could use the jsMath2jax preprocessor rather than the tex2jax preprocessor and it would only convert the math contained within those elements.

Jonathan Fine

In the URL below Georg Brandl writes: So if I understand correctly, first MathJax needs to provide an API that we could use?

I suggest that a suitable expert in this list supplies the API that Georg asks for. I think this can be done without my being involved. If you have specific questions related to Sphinx please use the URL below.

https://bitbucket.org/birkenfeld/sphinx/issue/1023/mathjax-too-keen-to-convert-tex-markup-in

Davide P. Cervone dpvc closed this December 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.