readme tweaks

This commit is contained in:
Sindre Sorhus 2015-10-05 22:36:26 +07:00
parent 262274af86
commit 8d599972ee

View file

@ -45,7 +45,7 @@ $ npm install --save chalk
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 ```js
var chalk = require('chalk'); const chalk = require('chalk');
// style a string // style a string
chalk.blue('Hello world!'); chalk.blue('Hello world!');
@ -73,17 +73,17 @@ chalk.green(
Easily define your own themes. Easily define your own themes.
```js ```js
var chalk = require('chalk'); const chalk = require('chalk');
var error = chalk.bold.red; const error = chalk.bold.red;
console.log(error('Error!')); 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 ```js
var name = 'Sindre'; const name = 'Sindre';
console.log(chalk.green('Hello %s'), name); console.log(chalk.green('Hello %s'), name);
//=> Hello Sindre //=> 'Hello Sindre'
``` ```
@ -104,7 +104,7 @@ Color support is automatically detected, but you can override it by setting the
If you need to change this in a reusable module create a new instance: If you need to change this in a reusable module create a new instance:
```js ```js
var ctx = new chalk.constructor({enabled: false}); const ctx = new chalk.constructor({enabled: false});
``` ```
### chalk.supportsColor ### chalk.supportsColor
@ -120,7 +120,7 @@ Exposes the styles as [ANSI escape codes](https://github.com/chalk/ansi-styles).
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own. Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own.
```js ```js
var chalk = require('chalk'); const chalk = require('chalk');
console.log(chalk.styles.red); console.log(chalk.styles.red);
//=> {open: '\u001b[31m', close: '\u001b[39m'} //=> {open: '\u001b[31m', close: '\u001b[39m'}
@ -141,8 +141,8 @@ Can be useful in combination with `.supportsColor` to strip color on externally
Example: Example:
```js ```js
var chalk = require('chalk'); const chalk = require('chalk');
var styledString = getText(); let styledString = getText();
if (!chalk.supportsColor) { if (!chalk.supportsColor) {
styledString = chalk.stripColor(styledString); styledString = chalk.stripColor(styledString);