1 | var chalk = require('chalk');
|
2 | var os = require('os');
|
3 | var lightColor = os.platform() === 'linux' ? chalk.white : chalk.grey;
|
4 |
|
5 |
|
6 | var colorBrushes = {
|
7 | "syntax": lightColor,
|
8 | "heading": chalk.cyan.bold,
|
9 | "hr": lightColor,
|
10 | "code": lightColor,
|
11 | "blockquote": chalk.blue,
|
12 | "bold": chalk.bold,
|
13 | "link": chalk.blue,
|
14 | "strong": chalk.bold,
|
15 | "em": chalk.italic,
|
16 | "del": chalk.strikethrough,
|
17 | "ul": null,
|
18 | "paragraph": null
|
19 | }
|
20 |
|
21 | function color(text, type) {
|
22 | var colorBrush = colorBrushes[type];
|
23 | if (colorBrush === null)
|
24 | return text;
|
25 | if (!colorBrush)
|
26 | colorBrush = chalk.stripColor;
|
27 | return colorBrush(text);
|
28 | }
|
29 |
|
30 | module.exports = color;
|