-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
1,574 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.