An open API service indexing awesome lists of open source software.

https://github.com/grawl/posthtml-richtypo

Process HTML node text with Richtypo
https://github.com/grawl/posthtml-richtypo

posthtml posthtml-plugin richtypo typography

Last synced: 5 months ago
JSON representation

Process HTML node text with Richtypo

Awesome Lists containing this project

README

          

# PostHTML [Richtypo] plugin

[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Build][build]][build-badge]
[![Coverage][cover]][cover-badge]
[![Standard Code Style][style]][style-url]
[![Chat][chat]][chat-badge]

Apply typography rules to text into HTML node

Before:

``` html

There are 1000 "rules" to enrich your text


```

After:

``` html

There are 1000 «rules» to enrich your text


```

## Install

```
npm i posthtml posthtml-richtypo
```

## Usage

``` js
const fs = require('fs');
const posthtml = require('posthtml');
const richtypoPlugin = require('posthtml-richtypo');
const {
quotes,
sectionSigns,
shortWords,
} = require('richtypo-rules-ru');

posthtml()
.use(richtypoPlugin({
attribute: 'data-typo',
rules: [
quotes,
sectionSigns,
shortWords,
],
}))
.process(html)
.then(result => fs.writeFileSync('./after.html', result.html));
```

## Options

#### `{string} attribute` to change text into

Default: `'data-richtypo'`

#### `{array} rules` to apply typography

Default: [`richtypo-rules-en`](https://www.npmjs.com/package/richtypo-rules-en)

[Richtypo rules](https://github.com/sapegin/richtypo.js/tree/master/packages)

## TODO

- [ ] More flexible replacement for 'attribute' (but PostHTML have nothing like CSS selectors)
- [ ] Allow providing rules by names, like 'ru' or 'fr'
- [ ] Remove `richtypo-rules-en` from dependencies, use common rules as fallback
- [ ] Fix tests
- [ ] Fix coverage

### Contributing

See [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs) and [contribution guide](contributing.md).

### License [MIT](license)

[Richtypo]: https://github.com/sapegin/richtypo.js

[npm]: https://img.shields.io/npm/v/posthtml-richtypo.svg
[npm-url]: https://npmjs.com/package/posthtml-richtypo

[deps]: https://david-dm.org/Grawl/posthtml-richtypo.svg
[deps-url]: https://david-dm.org/Grawl/posthtml-richtypo

[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/

[build]: https://travis-ci.org/Grawl/posthtml-richtypo.svg?branch=master
[build-badge]: https://travis-ci.org/Grawl/posthtml-richtypo?branch=master

[cover]: https://coveralls.io/repos/Grawl/posthtml-richtypo/badge.svg?branch=master
[cover-badge]: https://coveralls.io/r/Grawl/posthtml-richtypo?branch=master

[chat]: https://badges.gitter.im/posthtml/posthtml.svg
[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"