Reindent environments

Since the previous commit deliberately avoided reindenting, this one here
does just that: reindenting the existing code.
This commit is contained in:
Martin von Gagern 2015-09-10 11:18:11 +02:00
parent 2a31a719ec
commit dae3a14744

View File

@ -81,98 +81,98 @@ function defineEnvironment(names, props, handler) {
} }
} }
// Arrays are part of LaTeX, defined in lttab.dtx so its documentation // Arrays are part of LaTeX, defined in lttab.dtx so its documentation
// is part of the source2e.pdf file of LaTeX2e source documentation. // is part of the source2e.pdf file of LaTeX2e source documentation.
defineEnvironment("array", { defineEnvironment("array", {
numArgs: 1 numArgs: 1
}, function(pos, mode, envName, colalign, positions) { }, function(pos, mode, envName, colalign, positions) {
var parser = this; var parser = this;
colalign = colalign.value.map ? colalign.value : [colalign]; colalign = colalign.value.map ? colalign.value : [colalign];
var cols = colalign.map(function(node) { var cols = colalign.map(function(node) {
var ca = node.value; var ca = node.value;
if ("lcr".indexOf(ca) !== -1) { if ("lcr".indexOf(ca) !== -1) {
return { return {
type: "align", type: "align",
align: ca align: ca
};
} else if (ca === "|") {
return {
type: "separator",
separator: "|"
};
}
throw new ParseError(
"Unknown column alignment: " + node.value,
parser.lexer, positions[1]);
});
var res = {
type: "array",
cols: cols,
hskipBeforeAndAfter: true // \@preamble in lttab.dtx
}; };
res = parseArray(parser, pos, mode, res); } else if (ca === "|") {
return res; return {
}); type: "separator",
separator: "|"
};
}
throw new ParseError(
"Unknown column alignment: " + node.value,
parser.lexer, positions[1]);
});
var res = {
type: "array",
cols: cols,
hskipBeforeAndAfter: true // \@preamble in lttab.dtx
};
res = parseArray(parser, pos, mode, res);
return res;
});
// The matrix environments of amsmath builds on the array environment // The matrix environments of amsmath builds on the array environment
// of LaTeX, which is discussed above. // of LaTeX, which is discussed above.
defineEnvironment([ defineEnvironment([
"matrix", "matrix",
"pmatrix", "pmatrix",
"bmatrix", "bmatrix",
"Bmatrix", "Bmatrix",
"vmatrix", "vmatrix",
"Vmatrix" "Vmatrix"
], { ], {
}, function(pos, mode, envName) { }, function(pos, mode, envName) {
var delimiters = { var delimiters = {
"matrix": null, "matrix": null,
"pmatrix": ["(", ")"], "pmatrix": ["(", ")"],
"bmatrix": ["[", "]"], "bmatrix": ["[", "]"],
"Bmatrix": ["\\{", "\\}"], "Bmatrix": ["\\{", "\\}"],
"vmatrix": ["|", "|"], "vmatrix": ["|", "|"],
"Vmatrix": ["\\Vert", "\\Vert"] "Vmatrix": ["\\Vert", "\\Vert"]
}[envName]; }[envName];
var res = { var res = {
type: "array", type: "array",
hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath
}; };
res = parseArray(this, pos, mode, res); res = parseArray(this, pos, mode, res);
if (delimiters) { if (delimiters) {
res.result = new ParseNode("leftright", { res.result = new ParseNode("leftright", {
body: [res.result], body: [res.result],
left: delimiters[0], left: delimiters[0],
right: delimiters[1] right: delimiters[1]
}, mode); }, mode);
} }
return res; return res;
}); });
// A cases environment (in amsmath.sty) is almost equivalent to // A cases environment (in amsmath.sty) is almost equivalent to
// \def\arraystretch{1.2}% // \def\arraystretch{1.2}%
// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
defineEnvironment("cases", { defineEnvironment("cases", {
}, function(pos, mode, envName) { }, function(pos, mode, envName) {
var res = { var res = {
type: "array", type: "array",
arraystretch: 1.2, arraystretch: 1.2,
cols: [{ cols: [{
type: "align", type: "align",
align: "l", align: "l",
pregap: 0, pregap: 0,
postgap: fontMetrics.metrics.quad postgap: fontMetrics.metrics.quad
}, { }, {
type: "align", type: "align",
align: "l", align: "l",
pregap: 0, pregap: 0,
postgap: 0 postgap: 0
}] }]
}; };
res = parseArray(this, pos, mode, res); res = parseArray(this, pos, mode, res);
res.result = new ParseNode("leftright", { res.result = new ParseNode("leftright", {
body: [res.result], body: [res.result],
left: "\\{", left: "\\{",
right: "." right: "."
}, mode); }, mode);
return res; return res;
}); });