MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / plainLine

Function plainLine

ui/src/lib/highlight.ts:97–109  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

95 * grammar — so a line rendered this way loses only its colouring.
96 */
97export function plainLine(text: string): Token[] {
98 const out: Token[] = [];
99 const ident = /[A-Za-z_$À-￿][\w$À-￿]*/g;
100 let at = 0;
101 let match: RegExpExecArray | null;
102 while ((match = ident.exec(text)) !== null) {
103 if (match.index > at) out.push({ cls: 'other', text: text.slice(at, match.index), col: at });
104 out.push({ cls: 'ident', text: match[0], col: match.index });
105 at = match.index + match[0].length;
106 }
107 if (at < text.length) out.push({ cls: 'other', text: text.slice(at), col: at });
108 return out;
109}
110
111/**
112 * The tokens for a slice, by 1-based file line.

Callers 3

toksFunction · 0.90
tokensByLineFunction · 0.85

Calls 2

pushMethod · 0.80
execMethod · 0.65

Tested by 1

toksFunction · 0.72