Skip to content

Commit

Permalink
Update AsciiMath to current master version
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Jul 18, 2018
1 parent 65685f4 commit bb1e450
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions unpacked/jax/input/AsciiMath/jax.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,15 @@ var AMsymbols = [
{input:"vec", tag:"mover", output:"\u2192", tex:null, ttype:UNARY, acc:true},
{input:"dot", tag:"mover", output:".", tex:null, ttype:UNARY, acc:true},
{input:"ddot", tag:"mover", output:"..", tex:null, ttype:UNARY, acc:true},
{input:"overarc", tag:"mover", output:"\u23DC", tex:"overparen", ttype:UNARY, acc:true},
{input:"ul", tag:"munder", output:"\u0332", tex:"underline", ttype:UNARY, acc:true},
{input:"ubrace", tag:"munder", output:"\u23DF", tex:"underbrace", ttype:UNARYUNDEROVER, acc:true},
{input:"obrace", tag:"mover", output:"\u23DE", tex:"overbrace", ttype:UNARYUNDEROVER, acc:true},
{input:"text", tag:"mtext", output:"text", tex:null, ttype:TEXT},
{input:"mbox", tag:"mtext", output:"mbox", tex:null, ttype:TEXT},
{input:"color", tag:"mstyle", ttype:BINARY},
{input:"id", tag:"mrow", ttype:BINARY},
{input:"class", tag:"mrow", ttype:BINARY},
{input:"cancel", tag:"menclose", output:"cancel", tex:null, ttype:UNARY},
AMquote,
{input:"bb", tag:"mstyle", atname:"mathvariant", atval:"bold", output:"bb", tex:null, ttype:UNARY},
Expand Down Expand Up @@ -908,11 +911,11 @@ function AMparseSexpr(str) { //parses str and returns [node,tailstr]
} else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
node = createMmlNode(symbol.tag,result[0]);
var accnode = createMmlNode("mo",document.createTextNode(symbol.output));
if (symbol.input=="vec" && (
(result[0].nodeName=="mrow" && result[0].childNodes.length==1
&& result[0].firstChild.firstChild.nodeValue !== null
if (symbol.input=="vec" && (
(result[0].nodeName=="mrow" && result[0].childNodes.length==1
&& result[0].firstChild.firstChild.nodeValue !== null
&& result[0].firstChild.firstChild.nodeValue.length==1) ||
(result[0].firstChild.nodeValue !== null
(result[0].firstChild.nodeValue !== null
&& result[0].firstChild.nodeValue.length==1) )) {
accnode.setAttribute("stretchy",false);
}
Expand Down Expand Up @@ -953,14 +956,22 @@ function AMparseSexpr(str) { //parses str and returns [node,tailstr]
if (result2[0]==null) return [createMmlNode("mo",
document.createTextNode(symbol.input)),str];
AMremoveBrackets(result2[0]);
if (symbol.input=="color") {
if (str.charAt(0)=="{") i=str.indexOf("}");
else if (str.charAt(0)=="(") i=str.indexOf(")");
else if (str.charAt(0)=="[") i=str.indexOf("]");
st = str.slice(1,i);
node = createMmlNode(symbol.tag,result2[0]);
node.setAttribute("mathcolor",st);
return [node,result2[1]];
if (['color', 'class', 'id'].indexOf(symbol.input) >= 0) {

// Get the second argument
if (str.charAt(0)=="{") i=str.indexOf("}");
else if (str.charAt(0)=="(") i=str.indexOf(")");
else if (str.charAt(0)=="[") i=str.indexOf("]");
st = str.slice(1,i);

// Make a mathml node
node = createMmlNode(symbol.tag,result2[0]);

// Set the correct attribute
if (symbol.input === "color") node.setAttribute("mathcolor", st)
else if (symbol.input === "class") node.setAttribute("class", st)
else if (symbol.input === "id") node.setAttribute("id", st)
return [node,result2[1]];
}
if (symbol.input=="root" || symbol.output=="stackrel")
newFrag.appendChild(result2[0]);
Expand Down

0 comments on commit bb1e450

Please sign in to comment.