[HOME] jsMath (Authors) [Prev][Up][Skip][Next]

Controlling tex2math Processing

Under some circumstances, you may want to be able to have tex2math process some portions of the page but not others. One such situation is when you use tex2math in a bulletin-board system, where the jsMath calls are inserted automatically by the system, so you can't control what is passed to them. In that case, you may want to be able to turn on or off tex2math by way of the HTML markup itself. You can do this using special class names to indicate what tex2math should process.

If you mark an element with CLASS="tex2math_ignore", then the contents of that element will not be processed by tex2math. This allows you to use the symbols that usually indicate mathematics without them having that special meaning. For example, in

    <DIV CLASS="tex2math_ignore">
      Normally, you enter mathematics between \( and \) or \[ and \].
would prevent tex2math from trying to interpret the two "and's" as mathematics.

It is also possible to mark an element with CLASS="tex2math_process" to have the opposite effect: to cause tex2math to look for mathematics within the element when it normally wouldn't. Usually, tex2math will ignore the contents of SCRIPT, NOSCRIPT, STYLE, TEXTAREA and PRE tags, as it usually is inappropriate to typeset mathematics within these items. If you really do want tex2math to process the text within one of these elements, you can use the CLASS to force that. For example, <PRE CLASS="tex2math_process"> would cause tex2math to process the contents of the PRE tag for mathematics.

Note that you can nest elements with CLASS="tex2math_process" inside ones of CLASS="tex2math_ignore" and vice versa, and you can nest as many layers deep as you wish. For example, you could make the BODY tag be CLASS="tex2math_ignore" in order to prohibit math processing, and then explicitly enable it on certain tags by using CLASS="tex2math_process". If the BODY needs to be set to a different class for display purposes, you can place a DIV with CLASS="tex2math_ignore" around the contents of the page to get the same effect.

Finally, it is possible to disable tex2math entirely on a page by including an element that is marked with ID="tex2math_off". Before doing any processing of the page, tex2math looks for an item with this ID, and if present, it does not run at all. This is intended for use in bulletin-board systems, where you don't control the complete content on the page. This lets you mark a page as not being appropriate for jsMath using only the text you can insert. For example, if you add

    <SPAN ID="tex2math_off"></SPAN>
anywhere on the page, then tex2math will not run. Note that if you use tex2math on a system where you are not the only one who can enter text, it is possible for others to include such a tag in their messages, perhaps maliciously, thus disabling the rest of the mathematics on that page. You can prevent this by including
    <SCRIPT> jsMath.text2math = {allowDisableTag: 0} </SCRIPT>
in your web page before loading tex2math, or if you are using the easy/load.js file to load jsMath, by setting the allowDisableTag value to 0.

Get jsMath at SourceForge.net. Fast, secure and Free Open Source software downloads [HOME] jsMath web pages
Created: 10 Jul 2005
Last modified: 21 Mar 2007 22:10:45
Comments to: dpvc@union.edu
[Next] The tex2math plugin
[Skip] Browser Support for jsMath
[Up] Information for jsMath Authors
[Prev] Configuring jsMath