Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 9, 2018
1 parent dd055e8 commit ec15ded
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 75 deletions.
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@

# remark-normalize-headings

[![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david]
[![Build Status][travis-badge]][travis]
[![Dependency Status][david-badge]][david]

Providing multiple top-level headings per single Markdown document is confusing for tools that assume that there is only a single top-level heading that contains some meta-information (usually title) about the document.
Providing multiple top-level headings per single Markdown document is confusing
for tools that assume that there is only a single top-level heading that
contains some meta-information (usually title) about the document.

This [remark][] plugin makes sure that there is only one top-level heading in the document by adjusting headings depths accordingly.
This [remark][] plugin makes sure that there is only one top-level heading in
the document by adjusting headings depths accordingly.

Originally extracted from [remark-man][].

[remark]: https://github.com/wooorm/remark
[remark-man]: https://github.com/wooorm/remark-man
[mdast]: https://github.com/syntax-tree/mdast
[mdast-normalize-headings]: https://github.com/eush77/mdast-normalize-headings

[travis]: https://travis-ci.org/eush77/remark-normalize-headings
[travis-badge]: https://travis-ci.org/eush77/remark-normalize-headings.svg
[david]: https://david-dm.org/eush77/remark-normalize-headings
[david-badge]: https://david-dm.org/eush77/remark-normalize-headings.png

## Example

```js
Expand Down Expand Up @@ -62,20 +56,37 @@ Modifies AST in-place.

## CLI

```
```sh
$ remark -u remark-normalize-headings
```

## Related

- [mdast-normalize-headings][][mdast][] transformation utility that is in the core of this plugin.
* [mdast-normalize-headings][]
[mdast][] transformation utility that is in the core of this plugin.

## Install

```
```sh
npm install remark-normalize-headings
```

## License

MIT

[remark]: https://github.com/remarkjs/remark

[remark-man]: https://github.com/remarkjs/remark-man

[mdast]: https://github.com/syntax-tree/mdast

[mdast-normalize-headings]: https://github.com/eush77/mdast-normalize-headings

[travis]: https://travis-ci.org/eush77/remark-normalize-headings

[travis-badge]: https://travis-ci.org/eush77/remark-normalize-headings.svg

[david]: https://david-dm.org/eush77/remark-normalize-headings

[david-badge]: https://david-dm.org/eush77/remark-normalize-headings.png
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';
'use strict'

var normalizeHeadings = require('mdast-normalize-headings');
var normalizeHeadings = require('mdast-normalize-headings')


module.exports = function () {
return normalizeHeadings;
};
module.exports = function() {
return normalizeHeadings
}
27 changes: 25 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,33 @@
"mdast-normalize-headings": "^1.0.0"
},
"devDependencies": {
"prettier": "^1.14.2",
"remark": "^9.0.0",
"tape": "^4.0.0"
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.0.0",
"xo": "^0.22.0"
},
"scripts": {
"test": "tape test/*.js"
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"test-api": "node test",
"test": "npm run format && npm run test-api"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}
34 changes: 34 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict'

var test = require('tape')
var remark = require('remark')
var normalizeHeadings = require('.')

test('remark-normalize-headings', function(t) {
var parse = remark().data('settings', {position: false}).parse
var run = remark().use(normalizeHeadings).runSync

var input = [
'# One',
'# Two',
'## Level 3',
'### Level 4',
'#### Level 5',
'##### Level 6',
'###### Level 7'
].join('\n\n')

var output = [
'# One',
'## Two',
'### Level 3',
'#### Level 4',
'##### Level 5',
'###### Level 6',
'###### Level 7'
].join('\n\n')

t.deepEqual(run(parse(input)), parse(output))

t.end()
})
13 changes: 0 additions & 13 deletions test/hierarchy.in

This file was deleted.

13 changes: 0 additions & 13 deletions test/hierarchy.out

This file was deleted.

25 changes: 0 additions & 25 deletions test/test.js

This file was deleted.

0 comments on commit ec15ded

Please sign in to comment.