diff --git a/src/buildMathML.js b/src/buildMathML.js index 65572f4e..d4e2cb96 100644 --- a/src/buildMathML.js +++ b/src/buildMathML.js @@ -94,6 +94,19 @@ export const getVariant = function( return "italic"; } else if (font === "boldsymbol") { return "bold-italic"; + } else if (font === "mathbf") { + return "bold"; + } else if (font === "mathbb") { + return "double-struck"; + } else if (font === "mathfrak") { + return "fraktur"; + } else if (font === "mathscr" || font === "mathcal") { + // MathML makes no distinction between script and caligrahpic + return "script"; + } else if (font === "mathsf") { + return "sans-serif"; + } else if (font === "mathtt") { + return "monospace"; } let text = group.text; diff --git a/test/__snapshots__/mathml-spec.js.snap b/test/__snapshots__/mathml-spec.js.snap index 7ed2d0b0..c2975a3f 100644 --- a/test/__snapshots__/mathml-spec.js.snap +++ b/test/__snapshots__/mathml-spec.js.snap @@ -185,28 +185,8 @@ exports[`A MathML builder ligatures render properly 1`] = ` − - \`\`‘Hi----''’ + \`\`‘Hi----''’\`\`‘Hi----''’ - - - \`\` - - - ‘Hi - - - --- - - - - - - - '' - - - ’ - - \\text{\`\`\`Hi----'''}--\\texttt{\`\`\`Hi----'''}\\text{\\tt \`\`\`Hi----'''} diff --git a/test/katex-spec.js b/test/katex-spec.js index 10931283..78852e75 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -1833,11 +1833,11 @@ describe("A MathML font tree-builder", function() { const tree = getParsed(tex); const markup = buildMathML(tree, tex, defaultOptions).toMarkup(); expect(markup).toContain("A"); - expect(markup).toContain("x"); - expect(markup).toContain("2"); - expect(markup).toContain("\u03c9"); // \omega - expect(markup).toContain("\u03A9"); // \Omega - expect(markup).toContain("\u0131"); // \imath + expect(markup).toContain("x"); + expect(markup).toContain("2"); + expect(markup).toContain("\u03c9"); // \omega + expect(markup).toContain("\u03A9"); // \Omega + expect(markup).toContain("\u0131"); // \imath expect(markup).toContain("+"); }); @@ -1887,9 +1887,9 @@ describe("A MathML font tree-builder", function() { expect(markup).toContain("A"); expect(markup).toContain("x"); expect(markup).toContain("2"); - expect(markup).toContain("\u03c9"); // \omega + expect(markup).toContain("\u03c9"); // \omega expect(markup).toContain("\u03A9"); // \Omega - expect(markup).toContain("\u0131"); // \imath + expect(markup).toContain("\u0131"); // \imath expect(markup).toContain("+"); }); @@ -1898,13 +1898,11 @@ describe("A MathML font tree-builder", function() { const tree = getParsed(tex); const markup = buildMathML(tree, tex, defaultOptions).toMarkup(); expect(markup).toContain("A"); - expect(markup).toContain("x"); // script is caps only + expect(markup).toContain("x"); expect(markup).toContain("2"); - // MathJax marks everything below as "script" except \omega - // We don't have these glyphs in "caligraphic" and neither does MathJax - expect(markup).toContain("\u03c9"); // \omega - expect(markup).toContain("\u03A9"); // \Omega - expect(markup).toContain("\u0131"); // \imath + expect(markup).toContain("\u03c9"); // \omega + expect(markup).toContain("\u03A9"); // \Omega + expect(markup).toContain("\u0131"); // \imath expect(markup).toContain("+"); }); @@ -1915,11 +1913,9 @@ describe("A MathML font tree-builder", function() { expect(markup).toContain("A"); expect(markup).toContain("x"); expect(markup).toContain("2"); - // MathJax marks everything below as "fraktur" except \omega - // We don't have these glyphs in "fraktur" and neither does MathJax - expect(markup).toContain("\u03c9"); // \omega - expect(markup).toContain("\u03A9"); // \Omega - expect(markup).toContain("\u0131"); // \imath + expect(markup).toContain("\u03c9"); // \omega + expect(markup).toContain("\u03A9"); // \Omega + expect(markup).toContain("\u0131"); // \imath expect(markup).toContain("+"); }); @@ -1928,13 +1924,11 @@ describe("A MathML font tree-builder", function() { const tree = getParsed(tex); const markup = buildMathML(tree, tex, defaultOptions).toMarkup(); expect(markup).toContain("A"); - // MathJax marks everything below as "script" except \omega - // We don't have these glyphs in "script" and neither does MathJax - expect(markup).toContain("x"); - expect(markup).toContain("2"); - expect(markup).toContain("\u03c9"); // \omega - expect(markup).toContain("\u03A9"); // \Omega - expect(markup).toContain("\u0131"); // \imath + expect(markup).toContain("x"); + expect(markup).toContain("2"); + expect(markup).toContain("\u03c9"); // \omega + expect(markup).toContain("\u03A9"); // \Omega + expect(markup).toContain("\u0131"); // \imath expect(markup).toContain("+"); }); @@ -1945,9 +1939,9 @@ describe("A MathML font tree-builder", function() { expect(markup).toContain("A"); expect(markup).toContain("x"); expect(markup).toContain("2"); - expect(markup).toContain("\u03c9"); // \omega + expect(markup).toContain("\u03c9"); // \omega expect(markup).toContain("\u03A9"); // \Omega - expect(markup).toContain("\u0131"); // \imath + expect(markup).toContain("\u0131"); // \imath expect(markup).toContain("+"); });