* 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: Parser,
{
hskipBeforeAndAfter,
addJot,
cols,
arraystretch,
colSeparationType,
autoTag,
singleRow,
emptySingleRow,
maxNumCols,
leqno,
}: {
hskipBeforeAndAfter?: boolean;
addJot?: boolean;
cols?: AlignSpec[];
arraystretch?: number;
colSeparationType?: ColSeparationType;
autoTag?: boolean | null | undefined;
singleRow?: boolean;
emptySingleRow?: boolean;
maxNumCols?: number;
leqno?: boolean;
},
style: StyleStr,
)
| 87 | * ("text", "display", etc.), then each cell is cast into that style. |
| 88 | */ |
| 89 | function parseArray( |
| 90 | parser: Parser, |
| 91 | { |
| 92 | hskipBeforeAndAfter, |
| 93 | addJot, |
| 94 | cols, |
| 95 | arraystretch, |
| 96 | colSeparationType, |
| 97 | autoTag, |
| 98 | singleRow, |
| 99 | emptySingleRow, |
| 100 | maxNumCols, |
| 101 | leqno, |
| 102 | }: { |
| 103 | hskipBeforeAndAfter?: boolean; |
| 104 | addJot?: boolean; |
| 105 | cols?: AlignSpec[]; |
| 106 | arraystretch?: number; |
| 107 | colSeparationType?: ColSeparationType; |
| 108 | autoTag?: boolean | null | undefined; |
| 109 | singleRow?: boolean; |
| 110 | emptySingleRow?: boolean; |
| 111 | maxNumCols?: number; |
| 112 | leqno?: boolean; |
| 113 | }, |
| 114 | style: StyleStr, |
| 115 | ): ParseNode<"array"> { |
| 116 | parser.gullet.beginGroup(); |
| 117 | if (!singleRow) { |
| 118 | // \cr is equivalent to \\ without the optional size argument (see below) |
| 119 | // TODO: provide helpful error when \cr is used outside array environment |
| 120 | parser.gullet.macros.set("\\cr", "\\\\\\relax"); |
| 121 | } |
| 122 | |
| 123 | // Get current arraystretch if it's not set by the environment |
| 124 | if (!arraystretch) { |
| 125 | const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); |
| 126 | if (stretch == null) { |
| 127 | // Default \arraystretch from lttab.dtx |
| 128 | arraystretch = 1; |
| 129 | } else { |
| 130 | arraystretch = parseFloat(stretch); |
| 131 | if (!arraystretch || arraystretch < 0) { |
| 132 | throw new ParseError(`Invalid \\arraystretch: ${stretch}`); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // Start group for first cell |
| 138 | parser.gullet.beginGroup(); |
| 139 | |
| 140 | let row: AnyParseNode[] = []; |
| 141 | const body: AnyParseNode[][] = [row]; |
| 142 | const rowGaps = []; |
| 143 | const hLinesBeforeRow = []; |
| 144 | const tags: Array<AnyParseNode[] | boolean> | undefined = |
| 145 | (autoTag != null ? [] : undefined); |
| 146 |
no test coverage detected
searching dependent graphs…