Add semantics annotation to NativeMML output. This is done in the NativeMML output jax rather than the input jax so that it can be done for any input format (that provides an encoding for it). Also, it avoids having the Show As MathML output include the annotation. Resolves issue #814.
This commit is contained in:
parent
0ebff03dc1
commit
7a9833becd
|
@ -1276,6 +1276,7 @@ junk = null;
|
||||||
|
|
||||||
ASCIIMATH.Augment({
|
ASCIIMATH.Augment({
|
||||||
sourceMenuTitle: /*_(MathMenu)*/ ["AsciiMathInput","AsciiMath Input"],
|
sourceMenuTitle: /*_(MathMenu)*/ ["AsciiMathInput","AsciiMath Input"],
|
||||||
|
annotationEncoding: "text/x-asciimath",
|
||||||
|
|
||||||
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing AsciiMath
|
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing AsciiMath
|
||||||
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing AsciiMath
|
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing AsciiMath
|
||||||
|
|
|
@ -2061,6 +2061,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
sourceMenuTitle: /*_(MathMenu)*/ ["TeXCommands","TeX Commands"],
|
sourceMenuTitle: /*_(MathMenu)*/ ["TeXCommands","TeX Commands"],
|
||||||
|
annotationEncoding: "application/x-tex",
|
||||||
|
|
||||||
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing TeX
|
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing TeX
|
||||||
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing TeX
|
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing TeX
|
||||||
|
@ -2087,7 +2088,6 @@
|
||||||
this.prefilterHooks.Execute(data); math = data.math;
|
this.prefilterHooks.Execute(data); math = data.math;
|
||||||
try {
|
try {
|
||||||
mml = TEX.Parse(math).mml();
|
mml = TEX.Parse(math).mml();
|
||||||
// mml = MML.semantics(mml,MML.annotation(math).With({encoding:"application/x-tex"}));
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
if (!err.texError) {throw err}
|
if (!err.texError) {throw err}
|
||||||
mml = this.formatError(err,math,display,script);
|
mml = this.formatError(err,math,display,script);
|
||||||
|
|
|
@ -299,7 +299,7 @@
|
||||||
//
|
//
|
||||||
// Convert to MathML (if restarted, remove any partial math)
|
// Convert to MathML (if restarted, remove any partial math)
|
||||||
//
|
//
|
||||||
try {math.toNativeMML(mspan)} catch (err) {
|
try {math.toNativeMML(mspan,jax)} catch (err) {
|
||||||
if (err.restart) {while (mspan.firstChild) {mspan.removeChild(mspan.firstChild)}}
|
if (err.restart) {while (mspan.firstChild) {mspan.removeChild(mspan.firstChild)}}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -906,8 +906,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
MML.math.Augment({
|
MML.math.Augment({
|
||||||
toNativeMML: function (parent) {
|
toNativeMML: function (parent,jax) {
|
||||||
var tag = this.NativeMMLelement(this.type), math = tag, jax;
|
var tag = this.NativeMMLelement(this.type), math = tag;
|
||||||
|
var annotate = (jax ? MathJax.InputJax[jax.inputJax].annotationEncoding : null);
|
||||||
var i, m;
|
var i, m;
|
||||||
nMML.adjustWidths = [];
|
nMML.adjustWidths = [];
|
||||||
//
|
//
|
||||||
|
@ -921,6 +922,17 @@
|
||||||
//
|
//
|
||||||
if (nMML.widthBug) {tag = tag.appendChild(this.NativeMMLelement("mrow"))}
|
if (nMML.widthBug) {tag = tag.appendChild(this.NativeMMLelement("mrow"))}
|
||||||
//
|
//
|
||||||
|
// Addannotation if the input jax provides an annotation encoding
|
||||||
|
//
|
||||||
|
if (annotate) {
|
||||||
|
tag = tag.appendChild(this.NativeMMLelement("semantics"))
|
||||||
|
tag.appendChild(this.NativeMMLelement("mrow"));
|
||||||
|
var annotation = tag.appendChild(this.NativeMMLelement("annotation"));
|
||||||
|
annotation.appendChild(document.createTextNode(jax.originalText));
|
||||||
|
annotation.setAttribute("encoding",annotate);
|
||||||
|
tag = tag.firstChild; // mrow
|
||||||
|
}
|
||||||
|
//
|
||||||
// Add the children
|
// Add the children
|
||||||
//
|
//
|
||||||
for (i = 0, m = this.data.length; i < m; i++) {
|
for (i = 0, m = this.data.length; i < m; i++) {
|
||||||
|
@ -966,7 +978,6 @@
|
||||||
//
|
//
|
||||||
// Save size for later when we check if Web fonts have arrived
|
// Save size for later when we check if Web fonts have arrived
|
||||||
//
|
//
|
||||||
jax = HUB.getJaxFor(parent);
|
|
||||||
if (jax) {jax.NativeMML.scrollWidth = math.firstChild.scrollWidth}
|
if (jax) {jax.NativeMML.scrollWidth = math.firstChild.scrollWidth}
|
||||||
}
|
}
|
||||||
if (nMML.adjustWidths.length) {
|
if (nMML.adjustWidths.length) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user