Skip to content

Commit

Permalink
Fix parsing and output for \class{} and \unicode{}
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Apr 2, 2018
1 parent 1e28a76 commit a55da39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions unpacked/extensions/TeX/unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
{HD = HD.replace(/ /g,"").split(/,/); font = this.GetBrackets(name)}
else {font = HD; HD = null}
}
var n = this.trimSpaces(this.GetArgument(name)),
N = parseInt(n.match(/^x/) ? "0"+n : n);
var n = this.trimSpaces(this.GetArgument(name)).replace(/^0x/,"x");
if (!n.match(/^(x[0-9A-Fa-f]+|[0-9]+)$/)) {
TEX.Error(["BadUnicode","Argument to \\unicode must be a number"]);
}
var N = parseInt(n.match(/^x/) ? "0"+n : n);
if (!UNICODE[N]) {UNICODE[N] = [800,200,font,N]}
else if (!font) {font = UNICODE[N][2]}
if (HD) {
Expand All @@ -101,7 +104,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (font) {
UNICODE[N][2] = def.fontfamily = font.replace(/"/g,"'");
if (variant) {
if (variant.match(/bold/)) {def.fontweight = "bold"}
if (variant.match(/bold/)) {def.fontweight = "bold"}
if (variant.match(/italic|-mathit/)) {def.fontstyle = "italic"}
}
} else if (variant) {def.mathvariant = variant}
Expand Down
6 changes: 3 additions & 3 deletions unpacked/extensions/toMathML.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
if (this.mathvariant && this.toMathMLvariants[this.mathvariant])
{CLASS.push("MJX"+this.mathvariant)}
if (this.variantForm) {CLASS.push("MJX-variant")}
if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')}
if (CLASS.length) {attr.unshift('class="'+this.toMathMLquote(CLASS.join(" "))+'"')}
},
toMathMLattribute: function (value) {
if (typeof(value) === "string" &&
Expand Down Expand Up @@ -165,7 +165,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
var xmlEscapedTex = jax.originalText.replace(/[&<>]/g, function(item) {
return { '>': '&gt;', '<': '&lt;','&': '&amp;' }[item]
});
data.push(space+' <annotation encoding="'+annotation+'">'+xmlEscapedTex+"</annotation>");
data.push(space+' <annotation encoding="'+this.toMathMLquote(annotation)+'">'+xmlEscapedTex+"</annotation>");
data.push(space+" </semantics>");
}
return space+"<"+tag+attr+">\n"+data.join("\n")+"\n"+space+"</"+tag+">";
Expand Down Expand Up @@ -221,7 +221,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
});

MML.entity.Augment({
toMathML: function (space) {return (space||"") + "&"+this.data[0]+";<!-- "+this.toString()+" -->"}
toMathML: function (space) {return (space||"") + "&"+this.toMathMLquote(this.data[0])+";<!-- "+this.toString()+" -->"}
});

MML.xml.Augment({
Expand Down

0 comments on commit a55da39

Please sign in to comment.