Move remapping of <mo> contents to output jax, so that the original MathML is left unchanged
This commit is contained in:
parent
f2170f4c4a
commit
65892262ac
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
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
|
@ -145,8 +145,6 @@
|
||||||
if (child.nodeName === "#text") {
|
if (child.nodeName === "#text") {
|
||||||
if (mml.isToken && !mml.mmlSelfClosing) {
|
if (mml.isToken && !mml.mmlSelfClosing) {
|
||||||
var text = this.trimSpace(child.nodeValue);
|
var text = this.trimSpace(child.nodeValue);
|
||||||
if (mml.isa(MML.mo) && text.length === 1 && this.Remap[text.charAt(0)])
|
|
||||||
{text = this.Remap[text.charAt(0)]}
|
|
||||||
text = text.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
|
text = text.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
|
||||||
mml.Append(MML.chars(text));
|
mml.Append(MML.chars(text));
|
||||||
} else if (child.nodeValue.match(/\S/)) {
|
} else if (child.nodeValue.match(/\S/)) {
|
||||||
|
@ -187,16 +185,6 @@
|
||||||
MathJax.Hub.RestartAfter(MathJax.Ajax.Require(MATHML.entityDir+"/"+file+".js"));
|
MathJax.Hub.RestartAfter(MathJax.Ajax.Require(MATHML.entityDir+"/"+file+".js"));
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
},
|
|
||||||
|
|
||||||
//
|
|
||||||
// Characters to remap to better unicode values when they are
|
|
||||||
// single-character <mo> elements
|
|
||||||
//
|
|
||||||
Remap: {
|
|
||||||
'\u0027': '\u2032', // '
|
|
||||||
'\u002A': '\u2217', // *
|
|
||||||
'\u002D': '\u2212' // -
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
loaded: [] // the entity files that are loaded
|
loaded: [] // the entity files that are loaded
|
||||||
|
|
|
@ -1788,8 +1788,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.chars.Augment({
|
MML.chars.Augment({
|
||||||
toHTML: function (span,variant) {
|
toHTML: function (span,variant,remap,chars) {
|
||||||
var text = this.data.join("").replace(/[\u2061-\u2064]/g,""); // remove invisibles
|
var text = this.data.join("").replace(/[\u2061-\u2064]/g,""); // remove invisibles
|
||||||
|
if (remap) {text = remap(text,chars)}
|
||||||
if (!variant) {
|
if (!variant) {
|
||||||
var scale = Math.floor(100/HTMLCSS.scale+.5) + "%";
|
var scale = Math.floor(100/HTMLCSS.scale+.5) + "%";
|
||||||
HTMLCSS.addElement(span,"span",{style:{"font-size":scale}},[text]);
|
HTMLCSS.addElement(span,"span",{style:{"font-size":scale}},[text]);
|
||||||
|
@ -1858,7 +1859,7 @@
|
||||||
if (values.largeop)
|
if (values.largeop)
|
||||||
{variant = HTMLCSS.FONTDATA.VARIANT[values.displaystyle ? "-largeOp" : "-smallOp"]}
|
{variant = HTMLCSS.FONTDATA.VARIANT[values.displaystyle ? "-largeOp" : "-smallOp"]}
|
||||||
for (var i = 0, m = this.data.length; i < m; i++)
|
for (var i = 0, m = this.data.length; i < m; i++)
|
||||||
{if (this.data[i]) {this.data[i].toHTML(span,variant)}}
|
{if (this.data[i]) {this.data[i].toHTML(span,variant,this.HTMLremap,this.HTMLremapChars)}}
|
||||||
if (!span.bbox) {span.bbox = {w:0, h:0, d:0, rw:0, lw:0}}
|
if (!span.bbox) {span.bbox = {w:0, h:0, d:0, rw:0, lw:0}}
|
||||||
if (text.length !== 1) {delete span.bbox.skew}
|
if (text.length !== 1) {delete span.bbox.skew}
|
||||||
if (HTMLCSS.AccentBug && span.bbox.w === 0 && text.length === 1 && span.firstChild) {
|
if (HTMLCSS.AccentBug && span.bbox.w === 0 && text.length === 1 && span.firstChild) {
|
||||||
|
@ -1889,6 +1890,16 @@
|
||||||
this.HTMLhandleColor(span);
|
this.HTMLhandleColor(span);
|
||||||
return span;
|
return span;
|
||||||
},
|
},
|
||||||
|
HTMLremapChars: {
|
||||||
|
'-':"\u2212",
|
||||||
|
'*':"\u2217",
|
||||||
|
'"':"\u2033"
|
||||||
|
},
|
||||||
|
HTMLremap: function (text,map) {
|
||||||
|
text = text.replace(/'/g,"\u2032");
|
||||||
|
if (text.length === 1) {text = map[text]||text}
|
||||||
|
return text;
|
||||||
|
},
|
||||||
HTMLcanStretch: function (direction) {
|
HTMLcanStretch: function (direction) {
|
||||||
if (!this.Get("stretchy")) {return false}
|
if (!this.Get("stretchy")) {return false}
|
||||||
var c = this.data.join("");
|
var c = this.data.join("");
|
||||||
|
|
|
@ -1203,8 +1203,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.chars.Augment({
|
MML.chars.Augment({
|
||||||
toSVG: function (variant,scale) {
|
toSVG: function (variant,scale,remap,chars) {
|
||||||
return this.SVGhandleVariant(variant,scale,this.data.join("").replace(/[\u2061-\u2064]/g,"")); // remove invisibles
|
var text = this.data.join("").replace(/[\u2061-\u2064]/g,""); // remove invisibles
|
||||||
|
if (remap) {text = remap(text,chars)}
|
||||||
|
return this.SVGhandleVariant(variant,scale,text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MML.entity.Augment({
|
MML.entity.Augment({
|
||||||
|
@ -1224,7 +1226,7 @@
|
||||||
{variant = SVG.FONTDATA.VARIANT[values.displaystyle ? "-largeOp" : "-smallOp"]}
|
{variant = SVG.FONTDATA.VARIANT[values.displaystyle ? "-largeOp" : "-smallOp"]}
|
||||||
for (var i = 0, m = this.data.length; i < m; i++) {
|
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||||
if (this.data[i]) {
|
if (this.data[i]) {
|
||||||
var text = this.data[i].toSVG(variant,scale), x = svg.w;
|
var text = this.data[i].toSVG(variant,scale,this.SVGremap,this.SVGremapChars), x = svg.w;
|
||||||
if (x === 0 && -text.l > 10*text.w) {x += -text.l} // initial combining character doesn't combine
|
if (x === 0 && -text.l > 10*text.w) {x += -text.l} // initial combining character doesn't combine
|
||||||
svg.Add(text,x,0,true);
|
svg.Add(text,x,0,true);
|
||||||
if (text.skew) {svg.skew = text.skew}
|
if (text.skew) {svg.skew = text.skew}
|
||||||
|
@ -1240,6 +1242,16 @@
|
||||||
this.SVGsaveData(svg);
|
this.SVGsaveData(svg);
|
||||||
return svg;
|
return svg;
|
||||||
},
|
},
|
||||||
|
SVGremapChars: {
|
||||||
|
'-':"\u2212",
|
||||||
|
'*':"\u2217",
|
||||||
|
'"':"\u2033"
|
||||||
|
},
|
||||||
|
SVGremap: function (text,map) {
|
||||||
|
text = text.replace(/'/g,"\u2032");
|
||||||
|
if (text.length === 1) {text = map[text]||text}
|
||||||
|
return text;
|
||||||
|
},
|
||||||
SVGcanStretch: function (direction) {
|
SVGcanStretch: function (direction) {
|
||||||
if (!this.Get("stretchy")) {return false}
|
if (!this.Get("stretchy")) {return false}
|
||||||
var c = this.data.join("");
|
var c = this.data.join("");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user