Adds math commands, HTML rendering, and screenshotter tests.

This is part 2 of 3.  Part 1 added new fonts metrics.  Part 2 will add MathML support and unit tests.
This commit is contained in:
Kevin Barabash
2015-07-04 15:28:18 -06:00
committed by Kevin Barabash
parent f32d615813
commit fd2d58fd80
18 changed files with 338 additions and 34 deletions

View File

@@ -171,13 +171,11 @@ var makeNullDelimiter = function(options) {
*/
var groupTypes = {
mathord: function(group, options, prev) {
return buildCommon.mathit(
group.value, group.mode, options.getColor(), ["mord"]);
return buildCommon.makeOrd(group, options, "mathord");
},
textord: function(group, options, prev) {
return buildCommon.mathrm(
group.value, group.mode, options.getColor(), ["mord"]);
return buildCommon.makeOrd(group, options, "textord");
},
bin: function(group, options, prev) {
@@ -199,32 +197,32 @@ var groupTypes = {
className = "mord";
}
return buildCommon.mathrm(
return buildCommon.mathsym(
group.value, group.mode, options.getColor(), [className]);
},
rel: function(group, options, prev) {
return buildCommon.mathrm(
return buildCommon.mathsym(
group.value, group.mode, options.getColor(), ["mrel"]);
},
open: function(group, options, prev) {
return buildCommon.mathrm(
return buildCommon.mathsym(
group.value, group.mode, options.getColor(), ["mopen"]);
},
close: function(group, options, prev) {
return buildCommon.mathrm(
return buildCommon.mathsym(
group.value, group.mode, options.getColor(), ["mclose"]);
},
inner: function(group, options, prev) {
return buildCommon.mathrm(
return buildCommon.mathsym(
group.value, group.mode, options.getColor(), ["minner"]);
},
punct: function(group, options, prev) {
return buildCommon.mathrm(
return buildCommon.mathsym(
group.value, group.mode, options.getColor(), ["mpunct"]);
},
@@ -628,7 +626,7 @@ var groupTypes = {
// into appropriate outputs.
return makeSpan(
["mord", "mspace"],
[buildCommon.mathrm(group.value, group.mode)]
[buildCommon.mathsym(group.value, group.mode)]
);
} else {
// Other kinds of spaces are of arbitrary width. We use CSS to
@@ -712,7 +710,7 @@ var groupTypes = {
// operators, like \limsup
var output = [];
for (var i = 1; i < group.value.body.length; i++) {
output.push(buildCommon.mathrm(group.value.body[i], group.mode));
output.push(buildCommon.mathsym(group.value.body[i], group.mode));
}
base = makeSpan(["mop"], output, options.getColor());
}
@@ -819,26 +817,26 @@ var groupTypes = {
// good, but the offsets for the T, E, and X were taken from the
// definition of \TeX in TeX (see TeXbook pg. 356)
var k = makeSpan(
["k"], [buildCommon.mathrm("K", group.mode)]);
["k"], [buildCommon.mathsym("K", group.mode)]);
var a = makeSpan(
["a"], [buildCommon.mathrm("A", group.mode)]);
["a"], [buildCommon.mathsym("A", group.mode)]);
a.height = (a.height + 0.2) * 0.75;
a.depth = (a.height - 0.2) * 0.75;
var t = makeSpan(
["t"], [buildCommon.mathrm("T", group.mode)]);
["t"], [buildCommon.mathsym("T", group.mode)]);
var e = makeSpan(
["e"], [buildCommon.mathrm("E", group.mode)]);
["e"], [buildCommon.mathsym("E", group.mode)]);
e.height = (e.height - 0.2155);
e.depth = (e.depth + 0.2155);
var x = makeSpan(
["x"], [buildCommon.mathrm("X", group.mode)]);
["x"], [buildCommon.mathsym("X", group.mode)]);
return makeSpan(
["katex-logo"], [k, a, t, e, x], options.getColor());
["katex-logo", "mord"], [k, a, t, e, x], options.getColor());
},
overline: function(group, options, prev) {
@@ -1006,6 +1004,11 @@ var groupTypes = {
return makeSpan([options.style.reset(), newStyle.cls()], inner);
},
font: function(group, options, prev) {
var font = group.value.font;
return buildGroup(group.value.body, options.withFont(font), prev);
},
delimsizing: function(group, options, prev) {
var delim = group.value.value;