Skip to content

Commit

Permalink
Remove ~ from list chars. Fixes verbose/verb#70.
Browse files Browse the repository at this point in the history
  • Loading branch information
adjohnson916 committed Jul 4, 2015
1 parent 153877f commit ffe07ae
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Results in:
- a
* b
+ c
~ d
- e
- d
* e
```

**Roman numerals**
Expand Down
55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

> Generate a single formatted list item, allowing you to easily generate lists with proper indentation, bullets, numbers or other leading characters.
## Install with [npm](npmjs.org)
Install with [npm](https://www.npmjs.com/)

```bash
npm i list-item --save
```sh
$ npm i list-item --save
```

## Usage
Expand Down Expand Up @@ -36,8 +36,8 @@ Results in:
- a
* b
+ c
~ d
- e
- d
* e
```

**Roman numerals**
Expand Down Expand Up @@ -70,18 +70,25 @@ I. a
XLI. e
```


## API

### [listitem](index.js#L45)

Returns a function to generate a plain-text/markdown list-item, allowing options to be cached for subsequent calls.

* `options` **{String}**
- `nobullet` **{Boolean}**: Pass true if you only want the list iten and identation, but no bullets.
- `indent` **{String}**: The amount of leading indentation to use. default is ` `.
- `chars` **{String|Array}**: If a string is passed, [expand-range] will be used to generate an array of bullets (visit [expand-range] to see all options.) Or directly pass an array of bullets, numbers, letters or other characters to use for each list item. Default `['-', '*', '+', '~']`

* `fn` **{Function}**: pass a function [expand-range] to modify the bullet for an item as it's generated. See the [examples].
**Params**

*
`options` **{String}**

- `nobullet` **{Boolean}**: Pass true if you only want the list iten and identation, but no bullets.
- `indent` **{String}**: The amount of leading indentation to use. default is ``.
- `chars` **{String|Array}**: If a string is passed, [expand-range](https://github.com/jonschlinkert/expand-range)will be used to generate an array of bullets (visit [expand-range](https://github.com/jonschlinkert/expand-range)to see all options.) Or directly pass an array of bullets, numbers, letters or other characters to use for each list item. Default `['-', '*', '+']`

*
`fn` **{Function}**: pass a function [expand-range](https://github.com/jonschlinkert/expand-range)to modify the bullet for an item as it's generated. See the [examples].

**Example**

```js
var li = listitem(options);
Expand All @@ -96,32 +103,30 @@ li(2, 'Level 2 list item');
//=> ' + Level 2 list item'
```



## Run tests
Install dev dependencies.

```bash
npm i -d && npm test
```
Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/list-item/issues)

## Author

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License
Copyright (c) 2015 Jon Schlinkert
Released under the license

***
Copyright © 2015 Jon Schlinkert
Released under the MIT license.

_This file was generated by [verb](https://github.com/assemble/verb) on February 21, 2015._
***

[expand-range]: https://github.com/jonschlinkert/expand-range
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 03, 2015._
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = listitem;
* @param {String} `options`
* @option {Boolean} [options] `nobullet` Pass true if you only want the list iten and identation, but no bullets.
* @option {String} [options] `indent` The amount of leading indentation to use. default is ` `.
* @option {String|Array} [options] `chars` If a string is passed, [expand-range] will be used to generate an array of bullets (visit [expand-range] to see all options.) Or directly pass an array of bullets, numbers, letters or other characters to use for each list item. Default `['-', '*', '+', '~']`
* @option {String|Array} [options] `chars` If a string is passed, [expand-range] will be used to generate an array of bullets (visit [expand-range] to see all options.) Or directly pass an array of bullets, numbers, letters or other characters to use for each list item. Default `['-', '*', '+']`
* @param {Function} `fn` pass a function [expand-range] to modify the bullet for an item as it's generated. See the [examples].
* @api public
*/
Expand Down Expand Up @@ -79,6 +79,9 @@ function listitem(opts, fn) {
* Generate and cache the array of characters to use as
* bullets.
*
* - http://spec.commonmark.org/0.19/#list-items
* - https://daringfireball.net/projects/markdown/syntax#list
*
* TODO: split this out into simpler functions.
*
* @param {Object} `opts` Options to pass to [expand-range]
Expand All @@ -87,7 +90,7 @@ function listitem(opts, fn) {
*/

function character(opts, fn) {
var chars = opts.chars || ['-', '*', '+', '~'];
var chars = opts.chars || ['-', '*', '+'];
if (typeof chars === 'string') {
opts = Object.create(opts || {});
return function (sublvl) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"devDependencies": {
"mocha": "*",
"romanize": "^0.1.0",
"should": "*"
"should": "*",
"verb": "git://github.com/verbose/verb"
},
"keywords": [
"bullet",
Expand All @@ -46,4 +47,4 @@
"test",
"unordered"
]
}
}
36 changes: 18 additions & 18 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ describe('listitem', function () {
li(0, 'a').should.equal('- a');
li(1, 'a').should.equal(' * a');
li(2, 'a').should.equal(' + a');
li(3, 'a').should.equal(' ~ a');
li(3, 'a').should.equal(' - a');
});

it('should use an `indent` string when passed on the options:', function () {
li = listitem({indent: ' '});
li(0, 'a').should.equal('- a');
li(1, 'a').should.equal(' * a');
li(2, 'a').should.equal(' + a');
li(3, 'a').should.equal(' ~ a');
li(3, 'a').should.equal(' - a');
});

it('should respect zero indentation if define with `indent`:', function () {
li = listitem({indent: ''});
li(0, 'a').should.equal('- a');
li(1, 'a').should.equal('* a');
li(2, 'a').should.equal('+ a');
li(3, 'a').should.equal('~ a');
li(3, 'a').should.equal('- a');
});

it('should rotate default bullets:', function () {
li(0, 'a').should.equal('- a');
li(1, 'a').should.equal(' * a');
li(2, 'a').should.equal(' + a');
li(3, 'a').should.equal(' ~ a');
li(4, 'a').should.equal(' - a');
li(5, 'a').should.equal(' * a');
li(6, 'a').should.equal(' + a');
li(7, 'a').should.equal(' ~ a');
li(8, 'a').should.equal(' - a');
li(7, 'a').should.not.equal(' ~ a');
li(3, 'a').should.equal(' - a');
li(4, 'a').should.equal(' * a');
li(5, 'a').should.equal(' + a');
li(6, 'a').should.equal(' - a');
li(7, 'a').should.equal(' * a');
li(8, 'a').should.equal(' + a');
li(7, 'a').should.not.equal(' * a');
});
});

Expand All @@ -72,7 +72,7 @@ describe('custom characters', function () {
li(1, 'a').should.equal(' a');
li(2, 'a').should.equal(' a');
li(3, 'a').should.equal(' a');
li(7, 'a').should.not.equal(' ~ a');
li(7, 'a').should.not.equal(' + a');
});

it('should use an array of custom characters:', function () {
Expand All @@ -82,7 +82,7 @@ describe('custom characters', function () {
li(1, 'a').should.equal(' B a');
li(2, 'a').should.equal(' C a');
li(3, 'a').should.equal(' D a');
li(7, 'a').should.not.equal(' ~ a');
li(7, 'a').should.not.equal(' + a');
});

it('should rotate custom characters:', function () {
Expand All @@ -97,7 +97,7 @@ describe('custom characters', function () {
li(6, 'a').should.equal(' C a');
li(7, 'a').should.equal(' D a');
li(8, 'a').should.equal(' A a');
li(7, 'a').should.not.equal(' ~ a');
li(7, 'a').should.not.equal(' + a');
});

it('should expand a range of characters from a string:', function () {
Expand All @@ -108,7 +108,7 @@ describe('custom characters', function () {
li(2, 'a').should.equal(' 3 a');
li(3, 'a').should.equal(' 4 a');
li(4, 'a').should.equal(' 5 a');
li(7, 'a').should.not.equal(' ~ a');
li(7, 'a').should.not.equal(' + a');
});

it('should allow a function to modify the default characters:', function () {
Expand All @@ -119,8 +119,8 @@ describe('custom characters', function () {
li(0, 'a').should.equal('--- a');
li(1, 'a').should.equal(' *** a');
li(2, 'a').should.equal(' +++ a');
li(3, 'a').should.equal(' ~~~ a');
li(7, 'a').should.not.equal(' ~ a');
li(3, 'a').should.equal(' --- a');
li(7, 'a').should.not.equal(' + a');
});

it('should use a custom function when an array of chars is passed:', function () {
Expand All @@ -133,7 +133,7 @@ describe('custom characters', function () {
li(2, 'a').should.equal(' III. a');
li(3, 'a').should.equal(' IV. a');
li(4, 'a').should.equal(' V. a');
li(7, 'a').should.not.equal(' ~ a');
li(7, 'a').should.not.equal(' + a');
});

it('should use a custom function when characters are generated by expand-range:', function () {
Expand All @@ -146,7 +146,7 @@ describe('custom characters', function () {
li(2, 'a').should.equal(' XXI. a');
li(3, 'a').should.equal(' XXXI. a');
li(4, 'a').should.equal(' XLI. a');
li(7, 'a').should.not.equal(' ~ a');
li(7, 'a').should.not.equal(' + a');
});

it('should throw an error:', function () {
Expand Down

0 comments on commit ffe07ae

Please sign in to comment.