(themeName: string, width: number, dim: boolean)
| 942 | } |
| 943 | |
| 944 | render(themeName: string, width: number, dim: boolean): string[] | null { |
| 945 | const mode = detectColorMode(themeName) |
| 946 | const theme = buildTheme(themeName, mode) |
| 947 | const lines = this.code.split('\n') |
| 948 | // Rust .lines() drops trailing empty line from trailing \n |
| 949 | if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop() |
| 950 | const firstLine = lines[0] ?? null |
| 951 | const lang = detectLanguage(this.filePath, firstLine) |
| 952 | const hlState = { lang, stack: null } |
| 953 | |
| 954 | const maxDigits = String(lines.length).length |
| 955 | const effectiveWidth = Math.max(1, width - maxDigits - 2) |
| 956 | |
| 957 | const out: string[] = [] |
| 958 | for (let i = 0; i < lines.length; i++) { |
| 959 | const tokens = highlightLine(hlState, lines[i]!, theme) |
| 960 | const h: Highlight = { marker: null, lineNumber: i + 1, lines: [tokens] } |
| 961 | removeNewlines(h) |
| 962 | wrapText(h, effectiveWidth, theme) |
| 963 | addLineNumber(h, theme, maxDigits, dim) |
| 964 | out.push(...intoLines(h, dim, true, mode)) |
| 965 | } |
| 966 | return out |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | export function getSyntaxTheme(themeName: string): SyntaxTheme { |
nothing calls this directly
no test coverage detected