mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +00:00
Improve MathML fonts (#1965)
This commit is contained in:
@@ -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;
|
||||
|
@@ -185,28 +185,8 @@ exports[`A MathML builder ligatures render properly 1`] = `
|
||||
−
|
||||
</mo>
|
||||
<mtext mathvariant="monospace">
|
||||
\`\`‘Hi----''’
|
||||
\`\`‘Hi----''’\`\`‘Hi----''’
|
||||
</mtext>
|
||||
<mrow>
|
||||
<mtext>
|
||||
\`\`
|
||||
</mtext>
|
||||
<mtext mathvariant="monospace">
|
||||
‘Hi
|
||||
</mtext>
|
||||
<mtext>
|
||||
---
|
||||
</mtext>
|
||||
<mtext mathvariant="monospace">
|
||||
-
|
||||
</mtext>
|
||||
<mtext>
|
||||
''
|
||||
</mtext>
|
||||
<mtext mathvariant="monospace">
|
||||
’
|
||||
</mtext>
|
||||
</mrow>
|
||||
</mrow>
|
||||
<annotation encoding="application/x-tex">
|
||||
\\text{\`\`\`Hi----'''}--\\texttt{\`\`\`Hi----'''}\\text{\\tt \`\`\`Hi----'''}
|
||||
|
@@ -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("<mi mathvariant=\"double-struck\">A</mi>");
|
||||
expect(markup).toContain("<mi>x</mi>");
|
||||
expect(markup).toContain("<mn>2</mn>");
|
||||
expect(markup).toContain("<mi>\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"normal\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi>\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mi mathvariant=\"double-struck\">x</mi>");
|
||||
expect(markup).toContain("<mn mathvariant=\"double-struck\">2</mn>");
|
||||
expect(markup).toContain("<mi mathvariant=\"double-struck\">\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"double-struck\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi mathvariant=\"double-struck\">\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mo>+</mo>");
|
||||
});
|
||||
|
||||
@@ -1887,9 +1887,9 @@ describe("A MathML font tree-builder", function() {
|
||||
expect(markup).toContain("<mi mathvariant=\"bold\">A</mi>");
|
||||
expect(markup).toContain("<mi mathvariant=\"bold\">x</mi>");
|
||||
expect(markup).toContain("<mn mathvariant=\"bold\">2</mn>");
|
||||
expect(markup).toContain("<mi>\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"bold\">\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"bold\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi>\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mi mathvariant=\"bold\">\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mo>+</mo>");
|
||||
});
|
||||
|
||||
@@ -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("<mi mathvariant=\"script\">A</mi>");
|
||||
expect(markup).toContain("<mi>x</mi>"); // script is caps only
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">x</mi>");
|
||||
expect(markup).toContain("<mn mathvariant=\"script\">2</mn>");
|
||||
// MathJax marks everything below as "script" except \omega
|
||||
// We don't have these glyphs in "caligraphic" and neither does MathJax
|
||||
expect(markup).toContain("<mi>\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"normal\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi>\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mo>+</mo>");
|
||||
});
|
||||
|
||||
@@ -1915,11 +1913,9 @@ describe("A MathML font tree-builder", function() {
|
||||
expect(markup).toContain("<mi mathvariant=\"fraktur\">A</mi>");
|
||||
expect(markup).toContain("<mi mathvariant=\"fraktur\">x</mi>");
|
||||
expect(markup).toContain("<mn mathvariant=\"fraktur\">2</mn>");
|
||||
// MathJax marks everything below as "fraktur" except \omega
|
||||
// We don't have these glyphs in "fraktur" and neither does MathJax
|
||||
expect(markup).toContain("<mi>\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"normal\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi>\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mi mathvariant=\"fraktur\">\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"fraktur\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi mathvariant=\"fraktur\">\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mo>+</mo>");
|
||||
});
|
||||
|
||||
@@ -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("<mi mathvariant=\"script\">A</mi>");
|
||||
// MathJax marks everything below as "script" except \omega
|
||||
// We don't have these glyphs in "script" and neither does MathJax
|
||||
expect(markup).toContain("<mi>x</mi>");
|
||||
expect(markup).toContain("<mn>2</mn>");
|
||||
expect(markup).toContain("<mi>\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"normal\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi>\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">x</mi>");
|
||||
expect(markup).toContain("<mn mathvariant=\"script\">2</mn>");
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi mathvariant=\"script\">\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mo>+</mo>");
|
||||
});
|
||||
|
||||
@@ -1945,9 +1939,9 @@ describe("A MathML font tree-builder", function() {
|
||||
expect(markup).toContain("<mi mathvariant=\"sans-serif\">A</mi>");
|
||||
expect(markup).toContain("<mi mathvariant=\"sans-serif\">x</mi>");
|
||||
expect(markup).toContain("<mn mathvariant=\"sans-serif\">2</mn>");
|
||||
expect(markup).toContain("<mi>\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"sans-serif\">\u03c9</mi>"); // \omega
|
||||
expect(markup).toContain("<mi mathvariant=\"sans-serif\">\u03A9</mi>"); // \Omega
|
||||
expect(markup).toContain("<mi>\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mi mathvariant=\"sans-serif\">\u0131</mi>"); // \imath
|
||||
expect(markup).toContain("<mo>+</mo>");
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user