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

Function handler

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

Source from the content-addressed store, hash-verified

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

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