Feature request: Add ignoreClass to mml2jax configuration options
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.9k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
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 ] );
}
},
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with unpacked/extensions/mml2jax.js, especially its configuration and ProcessMathArray function, and compare the requested option with the patch included in the issue. Done means mml2jax accepts ignoreClass and skips matching elements while preserving the existing MathML processing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100