Add support for \text{rm,it,bf,tt,sf,normal}.

And allow \text to nest inside \text.
This commit is contained in:
Eddie Kohler
2016-11-28 11:39:28 -05:00
parent 576380c11c
commit e1c5f5db1c
6 changed files with 67 additions and 6 deletions

View File

@@ -1382,6 +1382,43 @@ describe("An HTML font tree-builder", function() {
expect(markup).toContain("<span class=\"mord mathfrak\">R</span>");
});
it("should render \\text{R} with the correct font", function() {
var markup = katex.renderToString("\\text{R}");
expect(markup).toContain("<span class=\"mord mathrm\">R</span>");
});
it("should render \\textit{R} with the correct font", function() {
var markup = katex.renderToString("\\textit{R}");
expect(markup).toContain("<span class=\"mord textit\">R</span>");
});
it("should render \\text{\\textit{R}} with the correct font", function() {
var markup = katex.renderToString("\\text{\\textit{R}}");
expect(markup).toContain("<span class=\"mord textit\">R</span>");
});
it("should render \\text{R\\textit{S}T} with the correct fonts", function() {
var markup = katex.renderToString("\\text{R\\textit{S}T}");
expect(markup).toContain("<span class=\"mord mathrm\">R</span>");
expect(markup).toContain("<span class=\"mord textit\">S</span>");
expect(markup).toContain("<span class=\"mord mathrm\">T</span>");
});
it("should render \\textbf{R} with the correct font", function() {
var markup = katex.renderToString("\\textbf{R}");
expect(markup).toContain("<span class=\"mord mathbf\">R</span>");
});
it("should render \\textsf{R} with the correct font", function() {
var markup = katex.renderToString("\\textsf{R}");
expect(markup).toContain("<span class=\"mord mathsf\">R</span>");
});
it("should render \\texttt{R} with the correct font", function() {
var markup = katex.renderToString("\\texttt{R}");
expect(markup).toContain("<span class=\"mord mathtt\">R</span>");
});
it("should render a combination of font and color changes", function() {
var markup = katex.renderToString("\\color{blue}{\\mathbb R}");
var span = "<span class=\"mord mathbb\" style=\"color:blue;\">R</span>";