MCPcopy Create free account
hub / github.com/codeaashu/claude-code / flattenHljs

Function flattenHljs

src/native-ts/color-diff/index.ts:469–484  ·  view source on GitHub ↗
(
  node: HljsNode | string,
  theme: Theme,
  parentScope: string | undefined,
  out: Block[],
)

Source from the content-addressed store, hash-verified

467}
468
469function flattenHljs(
470 node: HljsNode | string,
471 theme: Theme,
472 parentScope: string | undefined,
473 out: Block[],
474): void {
475 if (typeof node === 'string') {
476 const fg = scopeColor(parentScope, node, theme)
477 out.push([{ foreground: fg, background: theme.background }, node])
478 return
479 }
480 const scope = node.scope ?? node.kind ?? parentScope
481 for (const child of node.children) {
482 flattenHljs(child, theme, scope, out)
483 }
484}
485
486// result.emitter is in the public HighlightResult type, but rootNode is
487// internal to TokenTreeEmitter. Type guard validates the shape once so we

Callers 1

highlightLineFunction · 0.85

Calls 2

scopeColorFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected