MCPcopy
hub / github.com/KaTeX/KaTeX / buildGroup

Function buildGroup

src/buildHTML.ts:259–291  ·  view source on GitHub ↗
(
    group: AnyParseNode | null | undefined,
    options: Options,
    baseOptions?: Options,
)

Source from the content-addressed store, hash-verified

257 * between parents and children.
258 */
259export const buildGroup = function(
260 group: AnyParseNode | null | undefined,
261 options: Options,
262 baseOptions?: Options,
263): HtmlDomNode {
264 if (!group) {
265 return makeSpan();
266 }
267
268 if (groupBuilders[group.type]) {
269 // TODO(ts): groupBuilders is Record<string, HtmlBuilder<any>>;
270 // a type-safe registry would need a mapped type keyed by NodeType.
271 let groupNode: HtmlDomNode = groupBuilders[group.type](group, options);
272
273 // If the size changed between the parent and the current group, account
274 // for that size difference.
275 if (baseOptions && options.size !== baseOptions.size) {
276 groupNode = makeSpan(options.sizingClasses(baseOptions),
277 [groupNode], options);
278
279 const multiplier =
280 options.sizeMultiplier / baseOptions.sizeMultiplier;
281
282 groupNode.height *= multiplier;
283 groupNode.depth *= multiplier;
284 }
285
286 return groupNode;
287 } else {
288 throw new ParseError(
289 "Got group of unknown type: '" + group.type + "'");
290 }
291};
292
293/**
294 * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)

Callers 1

buildExpressionFunction · 0.70

Calls 2

makeSpanFunction · 0.90
sizingClassesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…