MCPcopy Create free account
hub / github.com/KaTeX/KaTeX / handler

Function handler

src/environments/array.ts:803–838  ·  view source on GitHub ↗
(context, args)

Source from the content-addressed store, hash-verified

801 numArgs: 1,
802 },
803 handler(context, args) {
804 // Since no types are specified above, the two possibilities are
805 // - The argument is wrapped in {} or [], in which case Parser's
806 // parseGroup() returns an "ordgroup" wrapping some symbol node.
807 // - The argument is a bare symbol node.
808 const symNode = checkSymbolNodeType(args[0]);
809 const colalign: AnyParseNode[] =
810 symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
811 const cols: AlignSpec[] = colalign.map(function(nde) {
812 const node = assertSymbolNodeType(nde);
813 const ca = node.text;
814 if ("lcr".includes(ca)) {
815 return {
816 type: "align",
817 align: ca,
818 };
819 } else if (ca === "|") {
820 return {
821 type: "separator",
822 separator: "|",
823 };
824 } else if (ca === ":") {
825 return {
826 type: "separator",
827 separator: ":",
828 };
829 }
830 throw new ParseError("Unknown column alignment: " + ca, nde);
831 });
832 const res: Parameters<typeof parseArray>[1] = {
833 cols,
834 hskipBeforeAndAfter: true, // \@preamble in lttab.dtx
835 maxNumCols: cols.length,
836 };
837 return parseArray(context.parser, res, dCellStyle(context.envName));
838 },
839 htmlBuilder,
840 mathmlBuilder,
841});

Callers

nothing calls this directly

Calls 13

checkSymbolNodeTypeFunction · 0.90
assertNodeTypeFunction · 0.90
assertSymbolNodeTypeFunction · 0.90
parseCDFunction · 0.90
parseArrayFunction · 0.85
dCellStyleFunction · 0.85
getAutoTagFunction · 0.85
fetchMethod · 0.80
consumeMethod · 0.80
expectMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected