Skip to content

Commit

Permalink
improved README
Browse files Browse the repository at this point in the history
  • Loading branch information
maboiteaspam committed Jul 15, 2015
1 parent 9aa00e0 commit 3e23269
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A module on top of [chjj/marked](https://github.com/chjj/marked) to extract a pa
Run the following commands to download and install the application:

```sh
$ npm i markdown-extract --save
npm i markdown-extract --save
```

## Usage
Expand All @@ -24,10 +24,12 @@ nd it s [markdown version](https://github.com/maboiteaspam/markdown-extract/blob

It exposes an unique function, with three signatures

```js
mdExtract (what[, markedOpt[, text]])
mdExtract (what, markedOpt)
mdExtract (what, text)

```

* __what__: The lookup object, regexp, or string
* __markedOpt__: The options passed to `marked`, default to `{gfm:true}`
* __text__: The markdown text to parse, it not provided it will fallback to `README.md` file on `cwd`
Expand All @@ -40,16 +42,16 @@ It will return only their text, as an array of string, in order of appearance in
* if it s a `string` or a `regexp`, it selects nodes with matching type or text property
* if it s an `array of string`, it selects nodes of those types
* if it s a `number`, it selects nodes with given depth
* if it s an `object`, then it can have type/text/depth properties with values that matches above logic.
* if it s an `object`, then it can have `type`/`text`/`depth` properties with values that matches above logic.
* if it s an `object`, and it s have a property (`grepNextParagraph` || `gnp`)==`true`,
then, the search is made based on `heading` nodes,
the results is al the following text of each matched `heading`.
the results is all the following `text` node of each matched `heading`.

The last option is the most interesting to me as you can match a `heading` such `## Usage`,
but gets only it s following `text`.

```
mdExtract ({type: /heading/, text: /Usage/, gnp: true}).join('\n')
```js
mdExtract ({type: /heading/, text: /Usage/, gnp: true}).join('\n')
```

## How to contribute
Expand Down

0 comments on commit 3e23269

Please sign in to comment.