InlineMath problem with dollar signs

15 vues
Accéder directement au premier message non lu

Carl Feagans

non lue,
22 juil. 2016, 15:40:2122/07/2016
à MathJax Users
I have a small science board that I run at thescienceforum.org and we've been using LaTex there for a while.

Recently, someone noticed odd formatting of posts, and we traced it down to the use of the dollar symbol twice in a given line. Looking over the posts, it seems that MathJax is somehow the culprit, but I can't figure out why html seems to be rendered outside the [LATEX] [/LATEX] tags of the BBCode.

Here's my footer code that uses the script:


<script type="text/x-mathjax-config">
 
MathJax.Hub.Config({
 extensions
: ["tex2jax.js"],
 jax
: ["input/TeX", "output/HTML-CSS"],
 tex2jax
: {
 inlineMath
: [['$','$'],['\\(','\\)']],
 processEscapes
: true
 
}
 
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>


Here's my BBCode:

[latex]{TEXT}[/latex]



And here's my HTML Replacement:
$ /displaystyle {TEXT}$



If someone were to type this phrase: "First ever league ace $133 and $50 first place!"

It becomes: Firsteverleagueace133 and 50 firstplace!

I've spent a couple hours reading over the documentation and understand that the inlineMath and processEscapes are key to it all, but I can't understand why this is formatting outside of the tags? I'm open to any ideas or at least an direction to get the info I need. 

My initial thought was to change the inlinMath section to something other than '$','$' but i'm not sure what would be the correct replacement. I've tried simply removing that bit, leaving just the '\\(','\\)' and even tried inserting '(',')' in place of the dollar signs, but no joy.

Thanks in advance for any input.

Peter Krautzberger

non lue,
22 juil. 2016, 16:40:5122/07/2016
à mathja...@googlegroups.com
Hi Carl,

Thanks for re-posting here.

To explain the behavior (which is expected): since the bbcode is converted to expressions surrounded by $...$, MathJax's TeX preprocessor can't know there's a difference between that and other uses of $...$ so it applies its usual routines to both.

In your setup, it's not clear to me what a good way of achieving a differentiation would be. It seems easiest to have the bbcode produce something that doesn't use $...$ delimiters (e.g., the default \( ... \), or shave some microseconds off processing and do what the pre-processors do: generate script tags of MathJax's custom type, cf http://docs.mathjax.org/en/latest/advanced/model.html#how-mathematics-is-stored-in-the-page). 

If you don't have control over the code that does this, then perhaps you're still able to work around this using the TeX pre-processor's skipTags, ingoreClass and processClass options (cf. http://docs.mathjax.org/en/latest/options/tex2jax.html); e.g., you could add the body tag to skipTags and have the bbcode output wrapped in a span with a class that you then add to processClass.

Anyway, those would be the easiest ways, I think.

Kind regards,
Peter.


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message