Merge pull request #1526 from dpvc/issue989
Make minus in <mn> produce U+2212 rather than U+002D. #989
This commit is contained in:
commit
119f050dd3
|
@ -190,7 +190,18 @@ MathJax.Extension["MathML/content-mathml"] = (function(HUB) {
|
||||||
*/
|
*/
|
||||||
appendToken: function(parentNode,name,textContent) {
|
appendToken: function(parentNode,name,textContent) {
|
||||||
var element = CToP.createElement(name);
|
var element = CToP.createElement(name);
|
||||||
element.appendChild(document.createTextNode(textContent));
|
if (name === 'mn' && textContent.substr(0,1) === "-") {
|
||||||
|
//
|
||||||
|
// use <mrow><mo>−</mo><mn>n</mn></mrow> instead of <mn>-n</mn>
|
||||||
|
//
|
||||||
|
element.appendChild(document.createTextNode(textContent.substr(1)));
|
||||||
|
var mrow = CToP.createElement('mrow');
|
||||||
|
CToP.appendToken(mrow,'mo','\u2212');
|
||||||
|
mrow.appendChild(element);
|
||||||
|
element = mrow;
|
||||||
|
} else {
|
||||||
|
element.appendChild(document.createTextNode(textContent));
|
||||||
|
}
|
||||||
parentNode.appendChild(element);
|
parentNode.appendChild(element);
|
||||||
return element;
|
return element;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1794,8 +1794,9 @@
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
MML.mn.Augment({
|
MML.mn.Augment({
|
||||||
|
CHTMLremapMinus: function (text) {return text.replace(/^-/,"\u2212")},
|
||||||
toCommonHTML: function (node) {
|
toCommonHTML: function (node) {
|
||||||
node = this.CHTMLdefaultNode(node);
|
node = this.CHTMLdefaultNode(node,{childOptions:{remap:this.CHTMLremapMinus}});
|
||||||
var bbox = this.CHTML, text = this.data.join("");
|
var bbox = this.CHTML, text = this.data.join("");
|
||||||
if (bbox.skew != null && text.length !== 1) delete bbox.skew;
|
if (bbox.skew != null && text.length !== 1) delete bbox.skew;
|
||||||
if (bbox.r > bbox.w && text.length === 1 && !this.CHTMLvariant.noIC) {
|
if (bbox.r > bbox.w && text.length === 1 && !this.CHTMLvariant.noIC) {
|
||||||
|
|
|
@ -2244,11 +2244,17 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mn.Augment({
|
MML.mn.Augment({
|
||||||
|
HTMLremapMinus: function (text) {return text.replace(/^-/,"\u2212")},
|
||||||
toHTML: function (span) {
|
toHTML: function (span) {
|
||||||
span = this.HTMLhandleSize(this.HTMLcreateSpan(span)); span.bbox = null;
|
span = this.HTMLhandleSize(this.HTMLcreateSpan(span)); span.bbox = null;
|
||||||
var variant = this.HTMLgetVariant();
|
var variant = this.HTMLgetVariant();
|
||||||
for (var i = 0, m = this.data.length; i < m; i++)
|
var remap = this.HTMLremapMinus;
|
||||||
{if (this.data[i]) {this.data[i].toHTML(span,variant)}}
|
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||||
|
if (this.data[i]) {
|
||||||
|
this.data[i].toHTML(span,variant,remap);
|
||||||
|
remap = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!span.bbox) {span.bbox = this.HTMLzeroBBox()}
|
if (!span.bbox) {span.bbox = this.HTMLzeroBBox()}
|
||||||
if (this.data.join("").length !== 1) {delete span.bbox.skew}
|
if (this.data.join("").length !== 1) {delete span.bbox.skew}
|
||||||
this.HTMLhandleSpace(span);
|
this.HTMLhandleSpace(span);
|
||||||
|
|
|
@ -890,6 +890,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MML.mn.Augment({
|
||||||
|
NativeMMLremapMinus: function (text) {return text.replace(/^-/,"\u2212")},
|
||||||
|
toNativeMML: function (parent) {
|
||||||
|
var tag = this.NativeMMLelement(this.type);
|
||||||
|
this.NativeMMLattributes(tag);
|
||||||
|
var remap = this.NativeMMLremapMinus;
|
||||||
|
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||||
|
if (this.data[i]) {
|
||||||
|
this.data[i].toNativeMML(tag,remap);
|
||||||
|
remap = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parent.appendChild(tag);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var fontDir = AJAX.fileURL(MathJax.OutputJax.fontDir+"/HTML-CSS/TeX/otf");
|
var fontDir = AJAX.fileURL(MathJax.OutputJax.fontDir+"/HTML-CSS/TeX/otf");
|
||||||
|
|
||||||
|
@ -1179,8 +1195,10 @@
|
||||||
//
|
//
|
||||||
// Add a text node
|
// Add a text node
|
||||||
//
|
//
|
||||||
toNativeMML: function (parent) {
|
toNativeMML: function (parent,remap) {
|
||||||
parent.appendChild(document.createTextNode(this.toString()));
|
var text = this.toString();
|
||||||
|
if (remap) text = remap(text);
|
||||||
|
parent.appendChild(document.createTextNode(text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1569,6 +1569,31 @@
|
||||||
return svg;
|
return svg;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MML.mn.Augment({
|
||||||
|
SVGremapMinus: function (text) {return text.replace(/^-/,"\u2212")},
|
||||||
|
toSVG: function () {
|
||||||
|
this.SVGgetStyles();
|
||||||
|
var variant = this.SVGgetVariant();
|
||||||
|
var svg = this.SVG(); this.SVGgetScale(svg);
|
||||||
|
this.SVGhandleSpace(svg);
|
||||||
|
var remap = this.SVGremapMinus;
|
||||||
|
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||||
|
if (this.data[i]) {
|
||||||
|
var child = svg.Add(this.data[i].toSVG(variant,svg.scale,remap),svg.w,0,true);
|
||||||
|
if (child.skew) {svg.skew = child.skew}
|
||||||
|
remap = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
svg.Clean(); var text = this.data.join("");
|
||||||
|
if (svg.skew && text.length !== 1) {delete svg.skew}
|
||||||
|
if (svg.r > svg.w && text.length === 1 && !variant.noIC)
|
||||||
|
{svg.ic = svg.r - svg.w; svg.w = svg.r}
|
||||||
|
this.SVGhandleColor(svg);
|
||||||
|
this.SVGsaveData(svg);
|
||||||
|
return svg;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
MML.mtext.Augment({
|
MML.mtext.Augment({
|
||||||
toSVG: function () {
|
toSVG: function () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user