MCPcopy Create free account
hub / github.com/TruthHun/BookStack / defineFunction

Function defineFunction

static/katex/katex.mjs:6163–6202  ·  view source on GitHub ↗
(_ref)

Source from the content-addressed store, hash-verified

6161
6162const _mathmlGroupBuilders = {};
6163function defineFunction(_ref) {
6164 let type = _ref.type,
6165 nodeType = _ref.nodeType,
6166 names = _ref.names,
6167 props = _ref.props,
6168 handler = _ref.handler,
6169 htmlBuilder = _ref.htmlBuilder,
6170 mathmlBuilder = _ref.mathmlBuilder;
6171 // Set default values of functions
6172 const data = {
6173 type,
6174 numArgs: props.numArgs,
6175 argTypes: props.argTypes,
6176 greediness: props.greediness === undefined ? 1 : props.greediness,
6177 allowedInText: !!props.allowedInText,
6178 allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
6179 numOptionalArgs: props.numOptionalArgs || 0,
6180 infix: !!props.infix,
6181 consumeMode: props.consumeMode,
6182 handler: handler
6183 };
6184
6185 for (let i = 0; i < names.length; ++i) {
6186 // TODO: The value type of _functions should be a type union of all
6187 // possible `FunctionSpec<>` possibilities instead of `FunctionSpec<*>`,
6188 // which is an existential type.
6189 // $FlowFixMe
6190 _functions[names[i]] = data;
6191 }
6192
6193 if (type) {
6194 if (htmlBuilder) {
6195 _htmlGroupBuilders[type] = htmlBuilder;
6196 }
6197
6198 if (mathmlBuilder) {
6199 _mathmlGroupBuilders[type] = mathmlBuilder;
6200 }
6201 }
6202}
6203/**
6204 * Use this to register only the HTML and MathML builders for a function (e.g.
6205 * if the function's ParseNode is generated in Parser.js rather than via a

Callers 2

defineFunctionBuildersFunction · 0.70
katex.mjsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected