Skip to content

Commit

Permalink
Refactor example in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 16, 2017
1 parent 7af9fca commit 38ec832
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,34 @@ npm install remark-heading-gap

## Example

Say our script, `example.js`, looks as follows:

```javascript
var fs = require('fs');
var remark = require('remark');
var gap = require('remark-heading-gap');
var markdown = '# remark-heading-gap\n\n## Example\n\n## API\n\n### remark.use(gap, [options])\n\n## Contributing';
var markdown = fs.readFileSync('example.md')
var result = remark().use(gap).processSync(markdown);
console.log(result);
```

And our markdown markdown file, `example.md`:

```markdown
# remark-heading-gap

## Example

## API

### remark.use(gap, [options])

## Contributing
```

Output:
Now, running `node example` yields:

```md
```markdown
# remark-heading-gap


Expand Down
13 changes: 10 additions & 3 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
// Say our script, `example.js`, looks as follows:
var fs = require('fs');
var remark = require('remark');
var gap = require('./dist/index.js');

var markdown = '# remark-heading-gap\n\n## Example\n\n## API\n\n### remark.use(gap, [options])\n\n## Contributing';
var markdown = fs.readFileSync('example.md')

var result = remark().use(gap).processSync(markdown);

// Output:
console.log('md', result.contents);
console.log(result);

// And our markdown markdown file, `example.md`:
console.log('markdown', String(markdown));

// Now, running `node example` yields:
console.log('markdown', String(result));
9 changes: 9 additions & 0 deletions example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# remark-heading-gap

## Example

## API

### remark.use(gap, [options])

## Contributing
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"pretest": "eslint src",
"markdown": "remark *.md --quiet",
"markdown": "remark README.md --quiet --output",
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"test": "npm run prepublish && npm run markdown && nyc ava src/__tests__"
},
Expand Down Expand Up @@ -54,7 +54,6 @@
},
"repository": "ben-eb/remark-heading-gap",
"remarkConfig": {
"output": true,
"plugins": {
"./dist/index.js": {},
"usage": {
Expand Down

0 comments on commit 38ec832

Please sign in to comment.