Expose some annotations to the Show Math As menu. Fix issue #357.
This commit is contained in:
parent
55b5803d0a
commit
bc9443b252
|
@ -962,6 +962,20 @@ MathJax.Hub.Config({
|
|||
showFontMenu: false,
|
||||
showContext: false,
|
||||
showDiscoverable: false,
|
||||
|
||||
//
|
||||
// These are the settings for the Annotation menu. If the <math> root has
|
||||
// a <semantics> child that contains one of the following annotation
|
||||
// formats, the source will be available via the "Show Math As" menu.
|
||||
// Each format has a list of possible encodings.
|
||||
//
|
||||
semanticsAnnotations: {
|
||||
"TeX": ["TeX", "LaTeX", "application/x-tex"],
|
||||
"StarMath": ["StarMath 5.0"],
|
||||
"Maple": ["Maple"],
|
||||
"Content MathML": ["MathML-Content", "application/mathml-content+xml"],
|
||||
"OpenMath": ["OpenMath"]
|
||||
},
|
||||
|
||||
//
|
||||
// These are the settings for the Show Source window. The initial
|
||||
|
|
|
@ -161,6 +161,24 @@
|
|||
source.items[0].name = jax.sourceMenuTitle;
|
||||
source.items[0].format = (jax.sourceMenuFormat||"MathML");
|
||||
source.items[1].name = INPUT[jax.inputJax].sourceMenuTitle;
|
||||
|
||||
//
|
||||
// Try and find each known annotation format and enable the menu
|
||||
// items accordingly.
|
||||
//
|
||||
var annotations = source.items[2]; annotations.hidden = true;
|
||||
var annotationItems = annotations.menu.items;
|
||||
annotationList = MathJax.Hub.Config.semanticsAnnotations;
|
||||
for (var i = 0, m = annotationItems.length; i < m; i++) {
|
||||
var name = annotationItems[i].name[1]
|
||||
if (jax.root.getAnnotation(name) !== null) {
|
||||
annotations.hidden = false;
|
||||
annotationItems[i].hidden = false;
|
||||
} else {
|
||||
annotationItems[i].hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer");
|
||||
MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer);
|
||||
return MENU.menu.Post(event);
|
||||
|
|
|
@ -711,6 +711,9 @@
|
|||
}
|
||||
} else if (this.format === "Error") {
|
||||
MENU.ShowSource.Text(MENU.jax.errorText,event);
|
||||
} else if (CONFIG.semanticsAnnotations[this.format]) {
|
||||
var annotation = MENU.jax.root.getAnnotation(this.format);
|
||||
if (annotation.data[0]) MENU.ShowSource.Text(annotation.data[0].toString());
|
||||
} else {
|
||||
if (MENU.jax.originalText == null) {
|
||||
alert(_("NoOriginalForm","No original form available"));
|
||||
|
@ -989,6 +992,20 @@
|
|||
menu.items.push(items[items.length-2],items[items.length-1]);
|
||||
};
|
||||
|
||||
//
|
||||
// Create the annotation menu from MathJax.Hub.config.semanticsAnnotations
|
||||
//
|
||||
MENU.CreateAnnotationMenu = function () {
|
||||
if (!MENU.menu) return;
|
||||
var menu = MENU.menu.Find("Show Math As","Annotation").menu;
|
||||
var annotations = CONFIG.semanticsAnnotations;
|
||||
for (var a in annotations) {
|
||||
if (annotations.hasOwnProperty(a)) {
|
||||
menu.items.push(ITEM.COMMAND([a,a], MENU.ShowSource, {hidden: true, nativeTouch: true, format: a}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
HUB.Register.StartupHook("End Config",function () {
|
||||
|
@ -1012,6 +1029,7 @@
|
|||
ITEM.SUBMENU(["Show","Show Math As"],
|
||||
ITEM.COMMAND(["MathMLcode","MathML Code"], MENU.ShowSource, {nativeTouch: true, format: "MathML"}),
|
||||
ITEM.COMMAND(["Original","Original Form"], MENU.ShowSource, {nativeTouch: true}),
|
||||
ITEM.SUBMENU(["Annotation","Annotation"], {hidden:true}),
|
||||
ITEM.RULE(),
|
||||
ITEM.CHECKBOX(["texHints","Show TeX hints in MathML"], "texHints")
|
||||
),
|
||||
|
@ -1095,6 +1113,7 @@
|
|||
}
|
||||
|
||||
MENU.CreateLocaleMenu();
|
||||
MENU.CreateAnnotationMenu();
|
||||
});
|
||||
|
||||
MENU.showRenderer = function (show) {
|
||||
|
|
|
@ -730,6 +730,10 @@ MathJax.ElementJax.mml.Augment({
|
|||
{if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}}
|
||||
if (this.data[0]) {this.updateTeXclass(this.data[0])}
|
||||
return prev;
|
||||
},
|
||||
getAnnotation: function (name) {
|
||||
if (this.data.length != 1) return null;
|
||||
return this.data[0].getAnnotation(name);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1174,7 +1178,18 @@ MathJax.ElementJax.mml.Augment({
|
|||
definitionURL: null,
|
||||
encoding: null
|
||||
},
|
||||
setTeXclass: MML.mbase.setChildTeXclass
|
||||
setTeXclass: MML.mbase.setChildTeXclass,
|
||||
getAnnotation: function (name) {
|
||||
var encodingList = MathJax.Hub.config.MathMenu.semanticsAnnotations[name];
|
||||
if (encodingList) {
|
||||
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||
var encoding = this.data[i].attr.encoding;
|
||||
if (encoding && encodingList.indexOf(encoding) !== -1)
|
||||
return this.data[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
MML.annotation = MML.mbase.Subclass({
|
||||
type: "annotation", isToken: true,
|
||||
|
@ -1235,7 +1250,11 @@ MathJax.ElementJax.mml.Augment({
|
|||
return "";
|
||||
},
|
||||
linebreakContainer: true,
|
||||
setTeXclass: MML.mbase.setChildTeXclass
|
||||
setTeXclass: MML.mbase.setChildTeXclass,
|
||||
getAnnotation: function (name) {
|
||||
if (this.data.length != 1) return null;
|
||||
return this.data[0].getAnnotation(name);
|
||||
}
|
||||
});
|
||||
|
||||
MML.chars = MML.mbase.Subclass({
|
||||
|
|
|
@ -184,9 +184,16 @@ MathJax.Localization.addTranslation("de","MathMenu",{
|
|||
// "Close",
|
||||
|
||||
EqSource:
|
||||
"Original MathJax Formel"
|
||||
"Original MathJax Formel",
|
||||
// "MathJax Equation Source"
|
||||
|
||||
"Annotation": "Annotation",
|
||||
"TeX": "TeX",
|
||||
"StarMath": "StarMath",
|
||||
"Maple": "Maple",
|
||||
"Content MathML": "Content MathML",
|
||||
"OpenMath": "OpenMath"
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -145,8 +145,14 @@ MathJax.Localization.addTranslation("en","MathMenu",{
|
|||
"Close", // NOTE: for closing button in the 'MathJax Menu => SHow Math As' window.
|
||||
|
||||
EqSource:
|
||||
"MathJax Equation Source"
|
||||
"MathJax Equation Source",
|
||||
|
||||
"Annotation": "Annotation",
|
||||
"TeX": "TeX",
|
||||
"StarMath": "StarMath",
|
||||
"Maple": "Maple",
|
||||
"Content MathML": "Content MathML",
|
||||
"OpenMath": "OpenMath"
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -145,8 +145,14 @@ MathJax.Localization.addTranslation("fr","MathMenu",{
|
|||
"Fermer",
|
||||
|
||||
EqSource:
|
||||
"Source de l'\u00E9quation MathJax"
|
||||
"Source de l'\u00E9quation MathJax",
|
||||
|
||||
"Annotation": "d'annotation",
|
||||
"TeX": "TeX",
|
||||
"StarMath": "StarMath",
|
||||
"Maple": "Maple",
|
||||
"Content MathML": "MathML de contenu",
|
||||
"OpenMath": "OpenMath"
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -179,9 +179,15 @@ MathJax.Localization.addTranslation("it","MathMenu",{
|
|||
//"Close", // NOTE: for closing button in the 'MathJax Menu => SHow Math As' window.
|
||||
|
||||
EqSource:
|
||||
"Codice sorgente formula MathJax"
|
||||
"Codice sorgente formula MathJax",
|
||||
//"MathJax Equation Source"
|
||||
|
||||
"Annotation": "Annotation",
|
||||
"TeX": "TeX",
|
||||
"StarMath": "StarMath",
|
||||
"Maple": "Maple",
|
||||
"Content MathML": "Content MathML",
|
||||
"OpenMath": "OpenMath"
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user