MCPcopy Create free account
hub / github.com/anus-dev/ANUS / highlightAndRenderLine

Function highlightAndRenderLine

packages/cli/src/ui/utils/CodeColorizer.tsx:93–110  ·  view source on GitHub ↗
(
  line: string,
  language: string | null,
  theme: Theme,
)

Source from the content-addressed store, hash-verified

91}
92
93function highlightAndRenderLine(
94 line: string,
95 language: string | null,
96 theme: Theme,
97): React.ReactNode {
98 try {
99 const getHighlightedLine = () =>
100 !language || !lowlight.registered(language)
101 ? lowlight.highlightAuto(line)
102 : lowlight.highlight(language, line);
103
104 const renderedNode = renderHastNode(getHighlightedLine(), theme, undefined);
105
106 return renderedNode !== null ? renderedNode : line;
107 } catch (_error) {
108 return line;
109 }
110}
111
112export function colorizeLine(
113 line: string,

Callers 2

colorizeLineFunction · 0.85
colorizeCodeFunction · 0.85

Calls 2

renderHastNodeFunction · 0.85
getHighlightedLineFunction · 0.85

Tested by

no test coverage detected