Feature request: Add ignoreClass to mml2jax configuration options
Created by: samdooley
It would be useful to allow a class name of elements whose contents should NOT be processed by mml2jax, similar to the tex2jax option. The use case I have in mind is to allow MathJax to process presentation MathML fragments in a page, while allowing other tools to process the content MathML in the page.
Here's a patch file for MathJax 2.2 that implements the support for ignoreClass.
Thanks, Sam Dooley
From 9f4a491a68bc7fd49709363acb3d5470e87b6964 Mon Sep 17 00:00:00 2001 From: Sam Dooley sam.dooley@pearson.com Date: Thu, 20 Jun 2013 13:21:35 -0600 Subject: [PATCH] Added ignoreClass to mml2jax configuration options --- unpacked/extensions/mml2jax.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/unpacked/extensions/mml2jax.js b/unpacked/extensions/mml2jax.js
index 1110a31..6d388be 100644
--- a/unpacked/extensions/mml2jax.js
+++ b/unpacked/extensions/mml2jax.js
@@ -29,6 +29,12 @@
MathJax.Extension.mml2jax = {
version: "2.2",
config: {
+ ignoreClass: "mml2jax_ignore",
+ // The class name of elements whose contents should
+ // NOT be processed by mml2jax. Note that this is a
+ // regular expression, so be sure to quote any regexp
+ // special characters.
+
preview: "alttext" // Use the <math> element's alttext as the
// preview. Set to "none" for no preview,
// or set to an array specifying an HTML snippet
@@ -86,16 +92,18 @@ MathJax.Extension.mml2jax = {
},
ProcessMathArray: function (math) {
- var i;
- if (math.length) {
- if (this.MathTagBug) {
- for (i = math.length-1; i >= 0; i--) {
- if (math[i].nodeName === "MATH") {this.ProcessMathFlattened(math[i])}
- else {this.ProcessMath(math[i])}
- }
- } else {
- for (i = math.length-1; i >= 0; i--) {this.ProcessMath(math[i])}
- }
+ if ( !math.length )
+ return;
+ if ( !this.ignoreClass )
+ this.ignoreClass = new RegExp("(^| )("+this.config.ignoreClass+")( |$)");
+ for ( var i = math.length - 1; i >= 0; i-- ) {
+ var cname = math[ i ].className || "";
+ if ( this.ignoreClass.exec( cname ) )
+ continue;
+ if ( this.MathTagBug && math[ i ].nodeName === "MATH" )
+ this.ProcessMathFlattened( math[ i ] );
+ else
+ this.ProcessMath( math[ i ] );
}
},