Skip to content

Commit

Permalink
Refactor readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 11, 2018
1 parent ceca70d commit bbe3d2d
Show file tree
Hide file tree
Showing 4 changed files with 1,574 additions and 114 deletions.
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(The MIT License)

Copyright (c) 2016 Denys Dovhan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
"nyc": "^12.0.2",
"prettier": "^1.14.2",
"remark": "^9.0.0",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"rimraf": "*",
"typographic-ellipses": "^1.0.11",
"typographic-quotes": "^2.0.1",
"xo": "^0.22.0"
},
"scripts": {
"format": "prettier --write \"**/*.js\" && xo --fix",
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"test-api": "mocha",
"test-coverage": "nyc --reporter lcov mocha test.js",
"test": "npm run format && npm run test-coverage"
Expand All @@ -63,5 +65,10 @@
"xo": {
"prettier": true,
"esnext": false
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}
149 changes: 71 additions & 78 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,119 @@
# remark-textr
# remark-textr [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]

[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Coveralls Status][coveralls-image]][coveralls-url]
[![Dependency Status][depstat-image]][depstat-url]
[Make your typography better][typewriter-habits] with [**remark**][remark] and
[**Textr**][textr] (skipping code).

> [Remark][remark] plugin for [Textr][textr] — modular tool to [make your typography better][typewriter-habits].
## Installation

Process your markdown with [Textr][textr] plugins, **skipping code**.
[npm][]:

* [Install](#install)
* [Usage](#usage)
* [API](#api)
* [CLI](#cli)

[typewriter-habits]: http://practicaltypography.com/typewriter-habits.html
[textr]: https://github.com/A/textr
```bash
npm install remark-textr
```

## Install
## Usage

npm install --save remark-textr
Say we have the following file, `example.md`:

## Usage
````markdown
## spread operator...

```js
import remark from 'remark';
import remarkTextr from 'remark-textr';
function(...args) { return args; }
```
````

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

```javascript
var vfile = require('to-vfile')
var remark = require('remark')
var textr = require('remark-textr')

// textr plugin — just function to replace triple dots to ellipses
const ellipses = input => input.replace(/\.{3}/gim, '');
function ellipses(input) {
return input.replace(/\.{3}/gim, '')
}

const text = `
## spread operator...
remark()
.use(textr, {plugins: [ellipses]})
.process(vfile.readSync('example.md'), function(err, file) {
if (err) throw err
console.log(String(file))
})
```

function(...args) { return args; }
`.trim();
Yields:

remark.use(remarkTextr, { plugins: [ ellipses ] }).process(text);/*
````markdown
## spread operator…

function(...args) { return args; } */
```js
function(...args) { return args; }
```
````

## API

### remark.use(remarkTextr[, remarkOptions])
### `remark.use(textr[, config])`

#### remarkOptions
##### `config.plugins`

Type: `Object`
Default: `{}`
List of [Textr][] plugins (`Array.<string|Function>?`).
They are available on npm, labelled with [textr][textr-plugins] keyword.
Also you can easily create new one, as shown in the example above.
If strings are passed in, those are required.

Contain `plugins` and `options` which are Textr’s options. Check out [Textr usage section][textr-usage].
##### `config.options`

[textr-usage]: https://github.com/A/textr#usage
Passed to [Textr][] as it’s options (`Object?`).
For example, you may want to set your [ISO 639][iso] [locale code][locale].
It’s important for stuff like the correct primary and secondary quotes.

##### remarkOptions.plugins
## Contribute

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

Array of [Textr][textr] plugins. They are available on npm, labelled with [textr][textr-plugins] keyword. Also you can easily create new one. Don’t be scared.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.

[textr-plugins]: https://www.npmjs.com/browse/keyword/textr
## License

##### remarkOptions.options
[MIT][license] © [Denys Dovhan][author]

Type: `Object`
Default: `{}`
<!-- Definitions -->

Any option was set in `options` will be passed into [Textr][textr] as it's options.
[build-badge]: https://img.shields.io/travis/remarkjs/remark-textr.svg

For example, you may want to set your [ISO 639][iso] [locale code][locale]. It's important for right correction, basically for proper primary and secondary quotes.
[build-status]: https://travis-ci.org/remarkjs/remark-textr

## CLI
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-textr.svg

`remark-textr` as remark plugin has no CLI itself, so you are gonna use remark CLI instead. So check the [remark-cli docs][remark-cli] first. `remark` and `remark-textr` both have to be installed. Also you have to define `textr` plugins as Array of Strings, but you are lucky and `remark-textr` will require them for you!
[coverage-status]: https://codecov.io/github/remarkjs/remark-textr

[remark-cli]: https://github.com/wooorm/remark/#cli
[t-base]: https://github.com/iamstarkov/typographic-base
[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg

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

remark --use "textr=plugins:['typographic-base']" README.md --output README.md
[license]: license

### config
[author]: http://denysdovhan.com

remark README.md --output README.md
[npm]: https://docs.npmjs.com/cli/install

With this `.remarkrc` config defined:
[remark]: https://github.com/remarkjs/remark

```json
{
"plugins": {
"textr": {
"plugins": [ "typographic-base"],
"options": { "locale": "en-us" }
}
}
}
```

## License
[contributing]: https://github.com/remarkjs/remark/blob/master/contributing.md

MIT © [Denys Dovhan](http://denysdovhan.com)
[coc]: https://github.com/remarkjs/remark/blob/master/code-of-conduct.md

[remark]: https://github.com/wooorm/remark
[use]: https://github.com/wooorm/remark#remarkuseplugin-options
[locale]: https://github.com/A/textr#locale-option-consistence
[iso]: http://www.wikiwand.com/en/List_of_ISO_639-1_codes

[remarkrc]: https://github.com/wooorm/remark/blob/master/doc/remarkrc.5.md
[remark-use]: https://github.com/wooorm/remark/blob/master/doc/remark.3.md#remarkuseplugin-options

[npm-url]: https://npmjs.org/package/remark-textr
[npm-image]: https://img.shields.io/npm/v/remark-textr.svg?style=flat-square
[iso]: http://www.wikiwand.com/en/List_of_ISO_639-1_codes

[travis-url]: https://travis-ci.org/denysdovhan/remark-textr
[travis-image]: https://img.shields.io/travis/denysdovhan/remark-textr.svg?style=flat-square
[typewriter-habits]: http://practicaltypography.com/typewriter-habits.html

[coveralls-url]: https://coveralls.io/r/denysdovhan/remark-textr
[coveralls-image]: https://img.shields.io/coveralls/denysdovhan/remark-textr.svg?style=flat-square
[textr]: https://github.com/A/textr

[depstat-url]: https://david-dm.org/denysdovhan/remark-textr
[depstat-image]: https://david-dm.org/denysdovhan/remark-textr.svg?style=flat-square
[textr-plugins]: https://www.npmjs.com/browse/keyword/textr
Loading

0 comments on commit bbe3d2d

Please sign in to comment.