(text: string)
| 435 | * @returns the text with highlighted JS/TS |
| 436 | */ |
| 437 | const javaScriptSyntaxHighlight = (text: string): string => { |
| 438 | if (text.trim().startsWith('//')) { |
| 439 | return dim(text); |
| 440 | } |
| 441 | |
| 442 | const words = text.split(' ').map((word: string) => { |
| 443 | if (JS_KEYWORDS.indexOf(word) > -1) { |
| 444 | return cyan(word); |
| 445 | } |
| 446 | return word; |
| 447 | }); |
| 448 | |
| 449 | return words.join(' '); |
| 450 | }; |
| 451 | |
| 452 | /** |
| 453 | * Highlights CSS syntax, taking in text and selectively highlighting keywords from the language |