-
Notifications
You must be signed in to change notification settings - Fork 3
/
mathjaxknowl3.js
48 lines (44 loc) · 1.36 KB
/
mathjaxknowl3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { Configuration } = MathJax._.input.tex.Configuration;
const { CommandMap } = MathJax._.input.tex.SymbolMap;
const NodeUtil = MathJax._.input.tex.NodeUtil.default;
var GetArgumentMML = function (parser, name) {
var arg = parser.ParseArg(name);
if (!NodeUtil.isInferred(arg)) {
return arg;
}
var children = NodeUtil.getChildren(arg);
if (children.length === 1) {
return children[0];
}
var mrow = parser.create("node", "mrow");
NodeUtil.copyChildren(arg, mrow);
NodeUtil.copyAttributes(arg, mrow);
return mrow;
};
let mathjaxKnowl = {};
/**
* Implements \knowl{url}{math}
* @param {TexParser} parser The calling parser.
* @param {string} name The TeX string
*/
mathjaxKnowl.Knowl = function (parser, name) {
var url = parser.GetArgument(name);
var arg = GetArgumentMML(parser, name);
var mrow = parser.create("node", "mrow", [arg], {
tabindex: '0',
"data-knowl": url
});
parser.Push(mrow);
};
new CommandMap(
"knowl",
{
knowl: ["Knowl"]
},
mathjaxKnowl
);
const configuration = Configuration.create("knowl", {
handler: {
macro: ["knowl"]
}
});