reshape-retext

1.0.1 • Public • Published

Reshape Retext

npm tests dependencies coverage

Plugin wrapper over Retext, an extensible system for analyzing and manipulating natural language.

Usage

const fs = require('fs')
const reshape = require('reshape')
const retext = require('reshape-retext')
const emoji = require('retext-emoji')
const smartypants = require('retext-smartypants')
 
reshape({
  plugins: retext([[emoji, { convert: 'encode' }], smartypants])
}).process(fs.readFileSync('path/to/file.html', 'utf8'))
  .then((result) => { fs.writeFileSync('path/to/file.html', 'utf8') })

Input html

<html>
<body>
  <article class="my-article">
    <h1>Hello "world"...</h1>
    <p>The three wise monkeys [. . .] sometimes called the three mystic
    apes--are a pictorial maxim. Together they embody the proverbial
    principle to ("see no evil, hear no evil, speak no evil"). The
    three monkeys are Mizaru (:see_no_evil:), covering his eyes, who
    sees no evil; Kikazaru (:hear_no_evil:), covering his ears, who
    hears no evil; and Iwazaru (:speak_no_evil:), covering his mouth,
    who speaks no evil.</p>
  </article>
</body>
</html>

Output html

<html>
<body>
  <article class="my-article">
    <h1>Hello “world”…</h1>
    <p>The three wise monkeys […] sometimes called the three mystic
    apes—are a pictorial maxim. Together they embody the proverbial
    principle to (“see no evil, hear no evil, speak no evil”). The
    three monkeys are Mizaru (🙈), covering his eyes, who
    sees no evil; Kikazaru (🙉), covering his ears, who
    hears no evil; and Iwazaru (🙊), covering his mouth,
    who speaks no evil.</p>
  </article>
</body>
</html>

Skipping Tags

If you'd like to have retext skip processing any any particular tag, you can add a retext-skip attribute to the tag. The plugin will not process the tag's contents, but will remove the attribute in the output. For example, the following input:

<p>:tada:</p>
<p retext-skip>:tada:</p>

...would produce this output:

<p>🎉</p>
<p>:tada:</p>

License & Contributing

Dependencies (3)

Dev Dependencies (6)

Package Sidebar

Install

npm i reshape-retext

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • jescalan