Skip to content

Commit

Permalink
improved README
Browse files Browse the repository at this point in the history
added mocha reports as MD file
  • Loading branch information
maboiteaspam committed Jul 15, 2015
1 parent e5b4261 commit 9aa00e0
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# markdown-extract

A module on top of https://github.com/chjj/marked to extract a paragraph from your markdown.
A module on top of [chjj/marked](https://github.com/chjj/marked) to extract a paragraph from your markdown.

## Installation
Run the following commands to download and install the application:
Expand All @@ -17,6 +17,9 @@ $ npm i markdown-extract --save
mdExtract ({type: /heading/, text: /Usage/, gnp: true}).join('\n')
```

See more in the [test suite](https://github.com/maboiteaspam/markdown-extract/blob/master/test/index.js) a
nd it s [markdown version](https://github.com/maboiteaspam/markdown-extract/blob/master/mocha.md).

## Documentation

It exposes an unique function, with three signatures
Expand Down
73 changes: 73 additions & 0 deletions mocha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# TOC
- [markdown extract](#markdown-extract)
<a name=""></a>

<a name="markdown-extract"></a>
# markdown extract
should find the heading with depth = 1.

```js
mdExtract(1)[0].should.eql('markdown-extract')
```

should find texts with the word Install inside.

```js
mdExtract('Instal')[0].should.eql('Installation')
mdExtract('Instal').length.should.eql(1)
```

should find text given their type as a string.

```js
mdExtract({type: 'heading'})[0].should.eql('markdown-extract')
mdExtract({type: 'heading'})[1].should.eql('Installation')
mdExtract({type: 'heading'}).length.should.eql(7)
```

should find text given their type as a regexp.

```js
mdExtract({type: /heading/})[0].should.eql('markdown-extract')
mdExtract({type: /heading/})[1].should.eql('Installation')
mdExtract({type: /heading/}).length.should.eql(7)
```

should find text given their type as an array.

```js
mdExtract({type: ['heading', 'paragraph']})[0].should.eql('markdown-extract')
mdExtract({type: ['heading', 'paragraph']})[2].should.eql('Installation')
mdExtract({type: ['heading', 'paragraph']}).length.should.eql(14)
```

should find next paragraph.

```js
mdExtract({gnp: true, type: ['heading'], text: /Installation/}).length.should.eql(2)
mdExtract({gnp: true, type: 'heading', text: /Installation/})[0].should.eql('Run the following commands to download and install the application:')
mdExtract({gnp: true, type: 'heading', text: /Installation/})[1].should.eql('$ npm i markdown-extract --save')
```

should accept marked options as a second argument.

```js
mdExtract('heading', {gfm:false}).length.should.eql(12)
mdExtract('heading', {gfm:false})[0].should.eql('markdown-extract')
mdExtract('heading', {gfm:false})[1].should.eql('Installation')
```

should accept MD content as second argument.

```js
mdExtract('heading', '# head1\ntext\n# head2\ntext\n').length.should.eql(2)
mdExtract('heading', '# head1\ntext\n# head2\ntext\n')[0].should.eql('head1')
```

should accept MD content as third argument.

```js
mdExtract('heading', {gfm:false}, '# head1\ntext\n# head2\ntext\n').length.should.eql(2)
mdExtract('heading', {gfm:false}, '# head1\ntext\n# head2\ntext\n')[0].should.eql('head1')
```

0 comments on commit 9aa00e0

Please sign in to comment.