Skip to content

Commit 5dcac77

Browse files
committed
Add comments (for Volker).
1 parent 9961697 commit 5dcac77

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

unpacked/jax/input/TeX/jax.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,12 +1685,33 @@
16851685
Entry: function (name) {
16861686
this.Push(STACKITEM.cell().With({isEntry: true, name: name}));
16871687
if (this.stack.Top().isCases) {
1688+
//
1689+
// Make second column be in \text{...} (unless it is already
1690+
// in a \text{...}, for backward compatibility).
1691+
//
16881692
var string = this.string;
16891693
var braces = 0, close = -1, i = this.i, m = string.length;
1694+
//
1695+
// Look through the string character by character...
1696+
//
16901697
while (i < m) {
16911698
var c = string.charAt(i);
1692-
if (c === "{") {braces++; i++}
1693-
else if (c === "}") {
1699+
if (c === "{") {
1700+
//
1701+
// Increase the nested brace count and go on
1702+
//
1703+
braces++;
1704+
i++;
1705+
} else if (c === "}") {
1706+
//
1707+
// If there are too many close braces, just end (we will get an
1708+
// error message later when the rest of the string is parsed)
1709+
// Otherwise
1710+
// decrease the nested brace count,
1711+
// if it is now zero and we haven't already marked the end of the
1712+
// first brace group, record the position (use to check for \text{} later)
1713+
// go on to the next character.
1714+
//
16941715
if (braces === 0) {
16951716
m = 0;
16961717
} else {
@@ -1701,11 +1722,29 @@
17011722
i++;
17021723
}
17031724
} else if (c === "&" && braces === 0) {
1725+
//
1726+
// Extra alignment tabs are not allowed in cases
1727+
//
17041728
TEX.Error(["ExtraAlignTab","Extra alignment tab in \\cases text"]);
17051729
} else if (c === "\\") {
1730+
//
1731+
// If the macro is \cr or \\, end the search, otherwise skip the macro
1732+
// (multi-letter names don't matter, as we will skip the rest of the
1733+
// characters in the main loop)
1734+
//
17061735
if (string.substr(i).match(/^((\\cr)[^a-zA-Z]|\\\\)/)) {m = 0} else {i += 2}
1707-
} else {i++}
1736+
} else {
1737+
//
1738+
// Go on to the next character
1739+
//
1740+
i++;
1741+
}
17081742
}
1743+
//
1744+
// Check if the second column text is already in \text{},
1745+
// If not, process the second column as text and continue parsing from there,
1746+
// (otherwise process the second column as normal, since it is in \text{}
1747+
//
17091748
var text = string.substr(this.i,i-this.i);
17101749
if (!text.match(/^\s*\\text[^a-zA-Z]/) || close !== text.replace(/\s+$/,'').length - 1) {
17111750
this.Push.apply(this,this.InternalMath(text,0));

0 commit comments

Comments
 (0)