How to render math in certain CSS classes rather than IDs

107 views
Skip to first unread message

c...@ias.edu

unread,
Sep 16, 2013, 5:25:08 PM9/16/13
to mathja...@googlegroups.com
Hi All,

I am the maintainer for Drupal MathJax module. We have a need for reasons particular to Drupal to display math only on certain page elements and I wonder if anyone knows the correct approach to configure MathJax accordingly.

I see that in the core configuration options you can pass MathJax an array of DOM elements, and it works, but it accepts IDs, not classes. Classes would make more sense for use because we may have several elements on a page that need math rendering and we could not predict the IDs needed. 

MathJax is flexible in the ways it can be configured, so is there another way to do this?

Peter Krautzberger

unread,
Sep 16, 2013, 5:42:00 PM9/16/13
to mathja...@googlegroups.com
Hi Chris,

First off, thanks for maintaining the excellent Drupal plugin. I think you want to check out the pre-processor documentation starting at http://docs.mathjax.org/en/latest/options/tex2jax.html for skipTags, ignoreClass and processClass.

Can you provide a bit of background on why you'd want to restrict MathJax to a certain class? Using the above might not be the best approach to solve the problem.

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/groups/opt_out.

cil...@gmail.com

unread,
Sep 16, 2013, 9:32:57 PM9/16/13
to mathja...@googlegroups.com
Peter,

Thank you for the reply, I will check out that page.

As for Drupal, here is the issue ticket with the information and background. Basically, in Drupal it is more common to define text filters to control the output of field text rather than to apply a filter globally. That may not explain it well enough, so please ask if I could go deeper on that.

Thanks, 
Chris

Peter Krautzberger

unread,
Sep 16, 2013, 9:48:24 PM9/16/13
to mathja...@googlegroups.com
Hi Chris,

Thanks for the link -- sounds like adding body to skipTag and then adding some classes to processClass is the way to go. Do you think that's the case?

I guess it depends a little on the point of view if that's "philosophically" right. For those who use MathJax as a MathML polyfill, it's only natural to assume that it works page wide -- it's just there to fill a gap in browser capability. Then again, those using TeX input might find odd if MathJax would not run e.g. in headers, TOCs etc. But I'm not a Drupal expert, so that's thankfully not my call ;-)

Let us know if there are any other questions we can help with.
Peter.

cil...@gmail.com

unread,
Sep 16, 2013, 9:51:50 PM9/16/13
to mathja...@googlegroups.com, cil...@gmail.com
Peter: This sort of configuration may work well for our needs because Drupal puts a class of "html" on <body>. I can wrap any of the selected MathJax areas with a "tex2jax" class. I am definitely open if you know of some better way, but this will do.

MathJax.Hub.Config({
  extensions: ["tex2jax.js"],
  jax: ["input/TeX","output/HTML-CSS"],
  tex2jax: {
    inlineMath: [ ['$','$'], ['\\(','\\)'] ],
    processEscapes: true,
    processClass: "tex2jax",
    ignoreClass: "html"
  },
  showProcessingMessages: false,
  messageStyle: "none"
});

Peter Krautzberger

unread,
Sep 16, 2013, 10:44:40 PM9/16/13
to mathja...@googlegroups.com
Hi Chris,

Looks good to me.

P.
Reply all
Reply to author
Forward
0 new messages