Add \mmlToken macro to allow direct creation of token MathML elements from within TeX, and use this to make \bmod, \mod, and \pmod produce better results (resolves issue #123)

This commit is contained in:
Davide P. Cervone 2011-07-26 22:43:20 -04:00
parent 86b344a63b
commit 557735366f
10 changed files with 35 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.InputJax.TeX=MathJax.InputJax({id:"TeX",version:"1.1.4",directory:MathJax.InputJax.directory+"/TeX",extensionDir:MathJax.InputJax.extensionDir+"/TeX",config:{TagSide:"right",TagIndent:"0.8em",MultLineWidth:"85%"}});MathJax.InputJax.TeX.Register("math/tex");MathJax.InputJax.TeX.loadComplete("config.js");
MathJax.InputJax.TeX=MathJax.InputJax({id:"TeX",version:"1.1.5",directory:MathJax.InputJax.directory+"/TeX",extensionDir:MathJax.InputJax.extensionDir+"/TeX",config:{TagSide:"right",TagIndent:"0.8em",MultLineWidth:"85%"}});MathJax.InputJax.TeX.Register("math/tex");MathJax.InputJax.TeX.loadComplete("config.js");

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@
MathJax.InputJax.TeX = MathJax.InputJax({
id: "TeX",
version: "1.1.4",
version: "1.1.5",
directory: MathJax.InputJax.directory + "/TeX",
extensionDir: MathJax.InputJax.extensionDir + "/TeX",

View File

@ -807,9 +807,9 @@
leqalignno: ['Matrix',null,null,"right left right",MML.LENGTH.THICKMATHSPACE+" 3em",".5em",'D'],
// TeX substitution macros
bmod: ['Macro','\\mathbin{\\rm mod}'],
pmod: ['Macro','\\pod{{\\rm mod}\\kern 6mu #1}',1],
mod: ['Macro','\\mathchoice{\\kern18mu}{\\kern12mu}{\\kern12mu}{\\kern12mu}{\\rm mod}\\,\\,#1',1],
bmod: ['Macro','\\mathbin{\\mmlToken{mo}{mod}}'],
pmod: ['Macro','\\pod{\\mmlToken{mi}{mod}\\kern 6mu #1}',1],
mod: ['Macro','\\mathchoice{\\kern18mu}{\\kern12mu}{\\kern12mu}{\\kern12mu}\\mmlToken{mi}{mod}\\,\\,#1',1],
pod: ['Macro','\\mathchoice{\\kern18mu}{\\kern8mu}{\\kern8mu}{\\kern8mu}(#1)',1],
iff: ['Macro','\\;\\Longleftrightarrow\\;'],
skew: ['Macro','{{#2{#3\\mkern#1mu}\\mkern-#1mu}{}}',3],
@ -862,6 +862,8 @@
cssId: ['Extension','HTML'],
// bbox: ['Extension','bbox'],
mmlToken: 'MmlToken',
require: 'Require'
},
@ -1246,6 +1248,21 @@
this.Push(mml);
},
MmlToken: function (name) {
var type = this.GetArgument(name),
attr = this.GetBrackets(name).replace(/^\s+/,""),
data = this.GetArgument(name),
def = {}, match;
if (!MML[type] || !MML[type].prototype.isToken) {TEX.Error(type+" is not a token element")}
while (attr !== "") {
match = attr.match(/^([a-z]+)\s*=\s*('[^']*'|"[^"]*"|[^ ]*)\s*/i);
if (!match) {TEX.Error("Invalid MathML attribute: "+attr)}
def[match[1]] = match[2].replace(/^(['"])(.*)\1$/,"$2");
attr = attr.substr(match[0].length);
}
this.Push(this.mmlToken(MML[type](data).With(def)));
},
Strut: function (name) {
this.Push(MML.mpadded(MML.mrow()).With({height: "8.6pt", depth: "3pt", width: 0}));
},