Skip to content

Commit

Permalink
Update build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 24, 2018
1 parent 38ec832 commit 8417080
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 180 deletions.
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
coverage
1 change: 1 addition & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__tests__
16 changes: 0 additions & 16 deletions CHANGELOG.md

This file was deleted.

94 changes: 58 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
# [remark]-heading-gap [![Build Status](https://travis-ci.org/ben-eb/remark-heading-gap.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/remark-heading-gap.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/remark-heading-gap.svg)][deps]
# remark-heading-gap [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]

> Adjust the gap between headings.
heading-gap support, without needing spaces, for [**remark**][remark].


## Install
## Installation

With [npm](https://npmjs.org/package/remark-heading-gap) do:
[npm][]:

```
```bash
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 = fs.readFileSync('example.md')
var result = remark().use(gap).processSync(markdown);
console.log(result);
```

And our markdown markdown file, `example.md`:
Say we have a markdown file, `example.md`, that looks as follows:

```markdown
# remark-heading-gap
Expand All @@ -39,6 +28,21 @@ And our markdown markdown file, `example.md`:
## Contributing
```

And our script, `example.js`, contains:

```javascript
const fs = require('fs')
const remark = require('remark')
const gap = require('remark-heading-gap')

const result = remark()
.use(gap)
.processSync(fs.readFileSync('example.md'))
.toString()

console.log(result)
```

Now, running `node example` yields:

```markdown
Expand All @@ -59,40 +63,58 @@ Now, running `node example` yields:

## API

remark-heading-gap ensures that automatically generated Markdown follows your
own rules for newlines in between section headings. From personal experience,
adding extra newlines helps to visualise breaks in sections, especially when
quickly scanning documentation.

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

#### options

##### `1|2|3|4|5|6`
remark-heading-gap ensures that automatically generated Markdown follows your
own rules for newlines in between section headings.
From personal experience, adding extra newlines helps to visualise breaks in
sections, especially when quickly scanning documentation.

Type: `object`
Default: `{before: '', after: ''}` (_except_ `2`, where `before` is `\n`)
#### `options.{1, 2, 3, 4, 5, 6}`

Pass a gap (Object, default: `{before: '\n', after: ''}` for `options.2`,
`{before: '', after: ''}` for all others)
Customise the gap that appears for up to 6 levels of heading; for example,
pass `{1: {before: '\n', after: '\n'}}` to double the gap for the first heading.
Note that both `before` and `after` accept a custom string so you can specify
`\r\n` instead if you choose; or add other presentational markers.


## Contributing
## Contribute

See [`contributing.md` in `remarkjs/remark`][contributing] for ways to get
started.

Pull requests are welcome. If you add functionality, then please add unit tests
to cover it.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.


## License

MIT © [Ben Briggs](http://beneb.info)
[MIT][license] © [Ben Briggs][author]

<!-- Definitions -->

[build-badge]: https://img.shields.io/travis/remarkjs/remark-heading-gap.svg

[build-status]: https://travis-ci.org/remarkjs/remark-heading-gap

[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-heading-gap.svg

[coverage-status]: https://codecov.io/github/remarkjs/remark-heading-gap

[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg

[chat]: https://gitter.im/remarkjs/Lobby

[license]: license

[author]: http://beneb.info

[ci]: https://travis-ci.org/ben-eb/remark-heading-gap
[npm]: https://docs.npmjs.com/cli/install

[deps]: https://gemnasium.com/ben-eb/remark-heading-gap
[remark]: https://github.com/remarkjs/remark

[npm]: http://badge.fury.io/js/remark-heading-gap
[contributing]: https://github.com/remarkjs/remark/blob/master/contributing.md

[remark]: /~https://github.com/wooorm/remark
[coc]: /~https://github.com/remarkjs/remark/blob/master/code-of-conduct.md
16 changes: 0 additions & 16 deletions example.js

This file was deleted.

9 changes: 0 additions & 9 deletions example.md

This file was deleted.

File renamed without changes.
133 changes: 77 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,7 @@
"name": "remark-heading-gap",
"version": "3.0.0",
"description": "Adjust the gap between headings.",
"main": "dist/index.js",
"files": [
"LICENSE-MIT",
"dist"
],
"scripts": {
"pretest": "eslint src",
"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__"
},
"engines": {
"node": ">=4"
},
"devDependencies": {
"ava": "^0.19.0",
"babel-cli": "^6.4.5",
"babel-core": "^6.4.5",
"babel-plugin-add-module-exports": "^0.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
"coveralls": "^2.11.6",
"del-cli": "^1.0.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1",
"nyc": "^11.0.0",
"remark": "^7.0.0",
"remark-cli": "^3.0.0",
"remark-usage": "^5.0.0"
},
"license": "MIT",
"keywords": [
"heading",
"gap",
Expand All @@ -45,31 +12,85 @@
"remark",
"markdown"
],
"license": "MIT",
"homepage": "/~https://github.com/ben-eb/remark-heading-gap",
"author": {
"name": "Ben Briggs",
"email": "beneb.info@gmail.com",
"url": "http://beneb.info"
"repository": "remarkjs/remark-heading-gap",
"bugs": "/~https://github.com/remarkjs/remark-heading-gap/issues",
"author": "Ben Briggs <beneb.info@gmail.com> (http://beneb.info)",
"contributors": [
"Ben Briggs <beneb.info@gmail.com> (http://beneb.info)",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"main": "dist/index.js",
"module": "src/index.js",
"files": [
"dist",
"src"
],
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0",
"ava": "1.0.0-rc.1",
"babel-plugin-add-module-exports": "^1.0.0",
"nyc": "^13.1.0",
"prettier": "^1.14.3",
"remark": "^10.0.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^4.0.0",
"xo": "^0.23.0"
},
"repository": "ben-eb/remark-heading-gap",
"remarkConfig": {
"plugins": {
"./dist/index.js": {},
"usage": {
"heading": "example"
}
},
"settings": {
"bullet": "*",
"fences": true,
"listItemIndent": "1"
}
"scripts": {
"prepublishOnly": "npm run build",
"build": "babel src --out-dir dist --ignore src/**/__tests__",
"format": "remark . -qfo && prettier \"**/*.js\" --write && xo --fix",
"test-api": "ava",
"test-coverage": "nyc --reporter lcov ava",
"test": "npm run build && npm run format && npm run test-coverage"
},
"browserslist": "> 2.5%, node 6",
"babel": {
"presets": [
"@babel/preset-env"
],
"plugins": [
"add-module-exports"
]
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"ava": {
"require": "babel-register"
"require": [
"@babel/register"
]
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"eslintConfig": {
"extends": "cssnano"
"xo": {
"prettier": true
},
"remarkConfig": {
"plugins": [
".",
"preset-wooorm",
[
"lint-maximum-line-length",
false
],
[
"lint-no-consecutive-blank-lines",
false
]
]
}
}
43 changes: 24 additions & 19 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import {readdirSync as directory, readFileSync as file} from 'fs';
import {join} from 'path';
import ava from 'ava';
import remark from 'remark';
import plugin from '..';
import {readdirSync as directory, readFileSync as file} from 'fs'
import {join} from 'path'
import test from 'ava'
import remark from 'remark'
import plugin from '..'

const base = join(__dirname, 'fixtures');
const base = join(__dirname, 'fixtures')

const specs = directory(base).reduce((tests, contents) => {
const parts = contents.split('.');
if (!tests[parts[0]]) {
tests[parts[0]] = {};
}
tests[parts[0]][parts[1]] = file(join(base, contents), 'utf-8');
return tests;
}, {});
const parts = contents.split('.')
if (!tests[parts[0]]) {
tests[parts[0]] = {}
}
tests[parts[0]][parts[1]] = file(join(base, contents), 'utf-8')
return tests
}, {})

Object.keys(specs).forEach(name => {
const spec = specs[name];
ava(name, t => {
const {contents} = remark().use(plugin).processSync(spec.fixture);
t.deepEqual(contents, spec.expected);
});
});
const spec = specs[name]
test(name, t => {
t.deepEqual(
remark()
.use(plugin)
.processSync(spec.fixture)
.toString(),
spec.expected
)
})
})
Loading

0 comments on commit 8417080

Please sign in to comment.