| 95 | * grammar — so a line rendered this way loses only its colouring. |
| 96 | */ |
| 97 | export 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. |