how to make processClass work?

75 views
Skip to first unread message

Ling Li

unread,
May 27, 2011, 6:09:55 PM5/27/11
to MathJax Users
processClass is supposed to specify CSS classes that MathJax would
scan even though the tags may be ignored. But I don't know how to
make it work. For example, MathJax still ignores the math equation in
the example below.

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
config: ["TeX-AMS_HTML.js"],
tex2jax: {
processClass: "latex",
},
});
</script>

<pre class="latex">
\( a + b \)
</pre>

fwiw, I know if I exclude "pre" from skipTags, MathJax will listen and
then process the above equation. But somehow it just doesn't listen
to processClass.
Message has been deleted

Sean Hogan

unread,
May 27, 2011, 9:09:11 PM5/27/11
to mathja...@googlegroups.com, Ling Li
You have some trailing commas that would cause problems in IE6,7,8.
Remove the commas in this section of code:

tex2jax: {
processClass: "latex",
},

Ling Li

unread,
May 29, 2011, 12:34:07 AM5/29/11
to MathJax Users
hmm, I removed the comma(s) and it didn't work either. And fwiw I was
using Firefox.

Sean Hogan

unread,
May 29, 2011, 3:42:25 AM5/29/11
to mathja...@googlegroups.com, Ling Li, Davide P. Cervone
I'm guessing a little here, but the documentation at
http://www.mathjax.org/docs/1.1/options/tex2jax.html says that
processClass "is used to turn on processing within tags that have been
marked as ignored or skipped". This suggests to me <pre
class="latex"></pre> would still be skipped because it is NOT WITHIN a
skipped tag. Rather, it is the skipped tag.

Davide, is that valid?

Sean

Davide P. Cervone

unread,
May 30, 2011, 9:26:15 AM5/30/11
to mathja...@googlegroups.com
The documentation is not clear enough about how skipTags, ignoreClass,
and processClass interact, and need to be updated to clarify that. It
turns out that skipTags takes precedence. (In fact, as it currently
stands, the contents of skipped elements are not scanned at all, and
the documentation is incorrect when it implies that processClass can
be used to turn on processing within a skipped tag. That is false at
the moment, as it only applies to tags marked with the ignoreClass).

I understand your desired usage, and will rethink the logic underlying
the preprocessor to see if it can be improved.

In the meantime, you might want to consider using something other than
<pre> as you container for your latex. For example, you could use
<div class="latex"> and have CSS like

.latex {
white-space: pre
}

(this is from memory, so the names might not be exactly right) in
order to make <div class="latex"> behave like <pre>, but allow MathJax
to process math inside of it.

Davide

Ling Li

unread,
May 30, 2011, 10:28:24 AM5/30/11
to MathJax Users
Thanks for making this clear. You are right---I should have used SPAN
or DIV instead of PRE, as MathJax renders the equations much nicer
without PRE.

Michal Frackowiak

unread,
Jun 1, 2011, 9:07:47 AM6/1/11
to MathJax Users
Am I wrong, or the current logic also makes it impossible to process
only certain elements as opposed to the whole document?

Something like:

tex2jax: {
skipTags: ["body"],
processClass: 'math_equation'
}

According to documentation it would process only elements with class
"math_equation". But it does not seem to work. Or is there a commonly-
used workaround I could use?

Davide P. Cervone

unread,
Jun 2, 2011, 7:37:28 AM6/2/11
to mathja...@googlegroups.com

Note that setting skipTags to ["body"] will mean that you no longer
skip the tags that are normally in skipTags (like script tags, and so
on). You would need to include those other tags as well.

But in any case, you are right, this does not work. Instead, you
could set the class for the body tag to be class="tex2jax_ignore", and
then it should work as you describe.

After the v1.1a release (in a few days), it will be possible to set a
global configuration parameter called "element" that is an array of
element ID's for those DOM elements to be processed, so that would be
another approach.

Davide

Reply all
Reply to author
Forward
Message has been deleted
0 new messages