readme - don't hard-wrap
no good reason to force a set line length when any editor supports soft-wrapping where you can set your own preferred size.
This commit is contained in:
parent
32ff12e4c3
commit
0f22588c59
1 changed files with 10 additions and 29 deletions
39
readme.md
39
readme.md
|
|
@ -2,14 +2,9 @@
|
||||||
|
|
||||||
> Terminal string styling done right
|
> Terminal string styling done right
|
||||||
|
|
||||||
[](https://travis-ci.org/sindresorhus/chalk)
|
[](https://travis-ci.org/sindresorhus/chalk) 
|
||||||

|
|
||||||
|
|
||||||
[colors.js](https://github.com/Marak/colors.js) used to be the most popular
|
[colors.js](https://github.com/Marak/colors.js) used to be 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.
|
||||||
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.**
|
**Chalk is a clean and focused alternative.**
|
||||||
|
|
||||||
|
|
@ -37,8 +32,7 @@ npm install --save chalk
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Chalk comes with an easy to use composable API where you just chain and nest
|
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||||
the styles you want.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var chalk = require('chalk');
|
var chalk = require('chalk');
|
||||||
|
|
@ -74,8 +68,7 @@ var error = chalk.bold.red;
|
||||||
console.log(error('Error!'));
|
console.log(error('Error!'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Take advantage of console.log [string
|
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
|
||||||
substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var name = 'Sindre';
|
var name = 'Sindre';
|
||||||
|
|
@ -90,10 +83,7 @@ console.log(chalk.green('Hello %s'), name);
|
||||||
|
|
||||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||||
|
|
||||||
Chain [styles](#styles) and call the last one as a method with a string
|
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`.
|
||||||
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.
|
Multiple arguments will be separated by space.
|
||||||
|
|
||||||
|
|
@ -103,8 +93,7 @@ Color support is automatically detected, but you can override it.
|
||||||
|
|
||||||
### chalk.supportsColor
|
### chalk.supportsColor
|
||||||
|
|
||||||
Detect whether the terminal [supports
|
Detect whether the terminal [supports color](https://github.com/sindresorhus/supports-color).
|
||||||
color](https://github.com/sindresorhus/supports-color).
|
|
||||||
|
|
||||||
Can be overridden by the user with the flags `--color` and `--no-color`.
|
Can be overridden by the user with the flags `--color` and `--no-color`.
|
||||||
|
|
||||||
|
|
@ -112,11 +101,9 @@ Used internally and handled for you, but exposed for convenience.
|
||||||
|
|
||||||
### chalk.styles
|
### chalk.styles
|
||||||
|
|
||||||
Exposes the styles as [ANSI escape
|
Exposes the styles as [ANSI escape codes](https://github.com/sindresorhus/ansi-styles).
|
||||||
codes](https://github.com/sindresorhus/ansi-styles).
|
|
||||||
|
|
||||||
Generally not useful, but you might need just the `.open` or `.close` escape
|
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own.
|
||||||
code if you're mixing externally styled strings with your own.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var chalk = require('chalk');
|
var chalk = require('chalk');
|
||||||
|
|
@ -135,8 +122,7 @@ Check whether a string [has color](https://github.com/sindresorhus/has-ansi).
|
||||||
|
|
||||||
[Strip color](https://github.com/sindresorhus/strip-ansi) from a string.
|
[Strip color](https://github.com/sindresorhus/strip-ansi) from a string.
|
||||||
|
|
||||||
Can be useful in combination with `.supportsColor` to strip color on externally
|
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
|
||||||
styled text when it's not supported.
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
@ -188,12 +174,7 @@ if (!chalk.supportsColor) {
|
||||||
|
|
||||||
## 256-colors
|
## 256-colors
|
||||||
|
|
||||||
Chalk does not support support anything other than the base eight colors, which
|
Chalk does not support support anything other than the base eight colors, which guarantees it will work on all terminals and systems. Some terminals, specifically `xterm` compliant ones, will support the full range of 8-bit colors. For this the lower level [ansi-256-colors](https://github.com/jbnicolai/ansi-256-colors) package can be used.
|
||||||
guarantees it will work on all terminals and systems. Some terminals,
|
|
||||||
specifically `xterm` compliant ones, will support the full range of 8-bit
|
|
||||||
colors. For this the lower level
|
|
||||||
[ansi-256-colors](https://github.com/jbnicolai/ansi-256-colors) package can be
|
|
||||||
used.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue