* Parse the body of the environment, with rows delimited by \\ and * columns delimited by &, and create a nested list in row-major order * with one group per cell. If given an optional argument style * ("text", "display", etc.), then each cell is cast into that style.
(parser, _ref, style)
| 10610 | |
| 10611 | |
| 10612 | function parseArray(parser, _ref, style) { |
| 10613 | let { |
| 10614 | hskipBeforeAndAfter, |
| 10615 | addJot, |
| 10616 | cols, |
| 10617 | arraystretch, |
| 10618 | colSeparationType, |
| 10619 | autoTag, |
| 10620 | singleRow, |
| 10621 | emptySingleRow, |
| 10622 | maxNumCols, |
| 10623 | leqno |
| 10624 | } = _ref; |
| 10625 | parser.gullet.beginGroup(); |
| 10626 | |
| 10627 | if (!singleRow) { |
| 10628 | // \cr is equivalent to \\ without the optional size argument (see below) |
| 10629 | // TODO: provide helpful error when \cr is used outside array environment |
| 10630 | parser.gullet.macros.set("\\cr", "\\\\\\relax"); |
| 10631 | } // Get current arraystretch if it's not set by the environment |
| 10632 | |
| 10633 | |
| 10634 | if (!arraystretch) { |
| 10635 | const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); |
| 10636 | |
| 10637 | if (stretch == null) { |
| 10638 | // Default \arraystretch from lttab.dtx |
| 10639 | arraystretch = 1; |
| 10640 | } else { |
| 10641 | arraystretch = parseFloat(stretch); |
| 10642 | |
| 10643 | if (!arraystretch || arraystretch < 0) { |
| 10644 | throw new src_ParseError("Invalid \\arraystretch: " + stretch); |
| 10645 | } |
| 10646 | } |
| 10647 | } // Start group for first cell |
| 10648 | |
| 10649 | |
| 10650 | parser.gullet.beginGroup(); |
| 10651 | let row = []; |
| 10652 | const body = [row]; |
| 10653 | const rowGaps = []; |
| 10654 | const hLinesBeforeRow = []; |
| 10655 | const tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent |
| 10656 | // whether this row should have an equation number. Simulate this with |
| 10657 | // a \@eqnsw macro set to 1 or 0. |
| 10658 | |
| 10659 | function beginRow() { |
| 10660 | if (autoTag) { |
| 10661 | parser.gullet.macros.set("\\@eqnsw", "1", true); |
| 10662 | } |
| 10663 | } |
| 10664 | |
| 10665 | function endRow() { |
| 10666 | if (tags) { |
| 10667 | if (parser.gullet.macros.get("\\df@tag")) { |
| 10668 | tags.push(parser.subparse([new Token("\\df@tag")])); |
| 10669 | parser.gullet.macros.set("\\df@tag", undefined, true); |
no test coverage detected