PostHTML Richtypo plugin ![PostHTML logo](https://camo.githubusercontent.com/1cb5ce095fc6bb81e4275a203108d7653a5d1bd53ee7400478822443ea2c9b65/687474703a2f2f706f737468746d6c2e6769746875622e696f2f706f737468746d6c2f6c6f676f2e737667)
Apply typography rules to text into HTML node
Before:
<p data-richtypo>There are 1000 "rules" to enrich your text</p>
After:
<p data-richtypo>There are 1000 «rules» to enrich your text</p>
npm i posthtml posthtml-richtypo
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));
Default: 'data-richtypo'
Default: richtypo-rules-en
- 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
See PostHTML Guidelines and contribution guide.