forked from orbit-oss/chalk
Linewraps at 80 where markdown syntax allows.
This commit is contained in:
parent
75f63a837a
commit
410bd76ad3
1 changed files with 21 additions and 8 deletions
29
readme.md
29
readme.md
|
|
@ -5,7 +5,11 @@
|
|||
[](https://travis-ci.org/sindresorhus/chalk)
|
||||

|
||||
|
||||
[colors.js](https://github.com/Marak/colors.js) is currently the most popular string styling module, but it has serious deficiencies like extending String.prototype which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.
|
||||
[colors.js](https://github.com/Marak/colors.js) is currently the most popular
|
||||
string styling module, but it has serious deficiencies like extending
|
||||
String.prototype which causes all kinds of
|
||||
[problems](https://github.com/yeoman/yo/issues/68). Although there are other
|
||||
ones, they either do too much or not enough.
|
||||
|
||||
**Chalk is a clean and focused alternative.**
|
||||
|
||||
|
|
@ -33,7 +37,8 @@ $ npm install --save chalk
|
|||
|
||||
## Usage
|
||||
|
||||
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||
Chalk comes with an easy to use composable API where you just chain and nest
|
||||
the styles you want.
|
||||
|
||||
```js
|
||||
var chalk = require('chalk');
|
||||
|
|
@ -65,7 +70,8 @@ var error = chalk.bold.red;
|
|||
console.log(error('Error!'));
|
||||
```
|
||||
|
||||
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
|
||||
Take advantage of console.log [string
|
||||
substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
|
||||
|
||||
```js
|
||||
var name = 'Sindre';
|
||||
|
|
@ -80,7 +86,10 @@ console.log(chalk.green('Hello %s'), name);
|
|||
|
||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||
|
||||
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `Chalk.red.yellow.green` is equivalent to `Chalk.green`.
|
||||
Chain [styles](#styles) and call the last one as a method with a string
|
||||
argument. Order doesn't matter, and later styles take precedent in case of a
|
||||
conflict. This simply means that `Chalk.red.yellow.green` is equivalent to
|
||||
`Chalk.green`.
|
||||
|
||||
Multiple arguments will be separated by space.
|
||||
|
||||
|
|
@ -90,7 +99,8 @@ Color support is automatically detected, but you can override it.
|
|||
|
||||
### chalk.supportsColor
|
||||
|
||||
Detect whether the terminal [supports color](https://github.com/sindresorhus/supports-color).
|
||||
Detect whether the terminal [supports
|
||||
color](https://github.com/sindresorhus/supports-color).
|
||||
|
||||
Can be overridden by the user with the flags `--color` and `--no-color`.
|
||||
|
||||
|
|
@ -98,9 +108,11 @@ Used internally and handled for you, but exposed for convenience.
|
|||
|
||||
### chalk.styles
|
||||
|
||||
Exposes the styles as [ANSI escape codes](https://github.com/sindresorhus/ansi-styles).
|
||||
Exposes the styles as [ANSI escape
|
||||
codes](https://github.com/sindresorhus/ansi-styles).
|
||||
|
||||
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with yours.
|
||||
Generally not useful, but you might need just the `.open` or `.close` escape
|
||||
code if you're mixing externally styled strings with yours.
|
||||
|
||||
```js
|
||||
var chalk = require('chalk');
|
||||
|
|
@ -119,7 +131,8 @@ Check whether a string [has color](https://github.com/sindresorhus/has-ansi).
|
|||
|
||||
[Strip color](https://github.com/sindresorhus/strip-ansi) from a string.
|
||||
|
||||
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
|
||||
Can be useful in combination with `.supportsColor` to strip color on externally
|
||||
styled text when it's not supported.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue