Skip to content

Commit

Permalink
readme tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 8, 2015
1 parent 9ddac30 commit cdf2412
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 'iojs'
- 'stable'
- '0.12'
- '0.10'
after_success: npm run coverage
25 changes: 15 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

> Wordwrap a string with [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)

## Install

```
Expand All @@ -12,10 +13,10 @@ $ npm install --save wrap-ansi
## Usage

```js
var chalk = require('chalk');
var wrapAnsi = require('wrap-ansi');
const chalk = require('chalk');
const wrapAnsi = require('wrap-ansi');

var input = 'The quick brown ' + chalk.red('fox jumped over ') +
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');

console.log(wrapAnsi(input, 20));
Expand All @@ -26,13 +27,9 @@ console.log(wrapAnsi(input, 20));

## API

### wrapAnsi(input, columns, opts)

wrap words to the specified column width. By default the wrap is `soft`, so long words may extend past the column length.
### wrapAnsi(input, columns, [options])

the following options can be provided:

* `hard`: `boolean`, should hard wrapping be enabled?
Wrap words to the specified column width.

#### input

Expand All @@ -46,12 +43,20 @@ Type: `number`

Number of columns to wrap the text to.

#### options.hard

Type: `boolean`
Default: `false`

By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.


## Related

- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating testing fixtures.
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.


## License

Expand Down

0 comments on commit cdf2412

Please sign in to comment.