Skip to content

Commit a314139

Browse files
committed
Merge branch 'issue814' into v2.4-beta. Issue #814.
2 parents 54007ab + 7a9833b commit a314139

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

unpacked/jax/input/AsciiMath/jax.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,7 @@ junk = null;
12761276

12771277
ASCIIMATH.Augment({
12781278
sourceMenuTitle: /*_(MathMenu)*/ ["AsciiMathInput","AsciiMath Input"],
1279+
annotationEncoding: "text/x-asciimath",
12791280

12801281
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing AsciiMath
12811282
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing AsciiMath

unpacked/jax/input/TeX/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,7 @@
20612061
},
20622062

20632063
sourceMenuTitle: /*_(MathMenu)*/ ["TeXCommands","TeX Commands"],
2064+
annotationEncoding: "application/x-tex",
20642065

20652066
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing TeX
20662067
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing TeX
@@ -2087,7 +2088,6 @@
20872088
this.prefilterHooks.Execute(data); math = data.math;
20882089
try {
20892090
mml = TEX.Parse(math).mml();
2090-
// mml = MML.semantics(mml,MML.annotation(math).With({encoding:"application/x-tex"}));
20912091
} catch(err) {
20922092
if (!err.texError) {throw err}
20932093
mml = this.formatError(err,math,display,script);

unpacked/jax/output/NativeMML/jax.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
//
301301
// Convert to MathML (if restarted, remove any partial math)
302302
//
303-
try {math.toNativeMML(mspan)} catch (err) {
303+
try {math.toNativeMML(mspan,jax)} catch (err) {
304304
if (err.restart) {while (mspan.firstChild) {mspan.removeChild(mspan.firstChild)}}
305305
throw err;
306306
}
@@ -916,8 +916,9 @@
916916
}
917917

918918
MML.math.Augment({
919-
toNativeMML: function (parent) {
920-
var tag = this.NativeMMLelement(this.type), math = tag, jax;
919+
toNativeMML: function (parent,jax) {
920+
var tag = this.NativeMMLelement(this.type), math = tag;
921+
var annotate = (jax ? MathJax.InputJax[jax.inputJax].annotationEncoding : null);
921922
var i, m;
922923
nMML.adjustWidths = [];
923924
//
@@ -931,6 +932,17 @@
931932
//
932933
if (nMML.widthBug) {tag = tag.appendChild(this.NativeMMLelement("mrow"))}
933934
//
935+
// Addannotation if the input jax provides an annotation encoding
936+
//
937+
if (annotate) {
938+
tag = tag.appendChild(this.NativeMMLelement("semantics"))
939+
tag.appendChild(this.NativeMMLelement("mrow"));
940+
var annotation = tag.appendChild(this.NativeMMLelement("annotation"));
941+
annotation.appendChild(document.createTextNode(jax.originalText));
942+
annotation.setAttribute("encoding",annotate);
943+
tag = tag.firstChild; // mrow
944+
}
945+
//
934946
// Add the children
935947
//
936948
for (i = 0, m = this.data.length; i < m; i++) {
@@ -976,7 +988,6 @@
976988
//
977989
// Save size for later when we check if Web fonts have arrived
978990
//
979-
jax = HUB.getJaxFor(parent);
980991
if (jax) {jax.NativeMML.scrollWidth = math.firstChild.scrollWidth}
981992
}
982993
if (nMML.adjustWidths.length) {

0 commit comments

Comments
 (0)