- posthtml ⇒
function
- version
PostHTML Instance
Returns: function - posthtml
Usage
import posthtml from 'posthtml'
import plugin from 'posthtml-plugin'
const ph = posthtml([ plugin() ])| Param | Type |
|---|---|
| plugins | Array |
Kind: global class
Requires: module:api, module:posthtml-parser, module:posthtml-render
Author: Ivan Voischev (@voischev),
Ivan Demidov (@scrum)
- PostHTML
- new PostHTML(plugins)
- .use(plugin) ⇒
Constructor - .process(html, options) ⇒
Object.<{html: String, tree: PostHTMLTree}>|Promise.<{html: String, tree: PostHTMLTree}>- ~options :
Object
- ~options :
| Param | Type | Description |
|---|---|---|
| plugins | Array |
An array of PostHTML plugins |
Kind: instance method of PostHTML
Returns: Constructor - - this(PostHTML)
Usage
ph.use((tree) => { tag: 'div', content: tree })
.process('<html>..</html>', {})
.then((result) => result))this: posthtml
| Param | Type | Description |
|---|---|---|
| plugin | function |
A PostHTML plugin |
postHTML.process(html, options) ⇒ Object.<{html: String, tree: PostHTMLTree}> | Promise.<{html: String, tree: PostHTMLTree}>
Kind: instance method of PostHTML
Returns: Object.<{html: String, tree: PostHTMLTree}> - - Sync ModePromise.<{html: String, tree: PostHTMLTree}> - - Async Mode (default)
Usage
Sync
ph.process('<html>..</html>', { sync: true }).htmlAsync
ph.process('<html>..</html>', {}).then((result) => result))| Param | Type | Description |
|---|---|---|
| html | String |
Input (HTML) |
| options | Object |
PostHTML Options |
Kind: inner property of process
Properties
| Name | Type | Description |
|---|---|---|
| options.sync | Boolean |
enables sync mode, plugins will run synchronously, throws an error when used with async plugins |
| options.parser | function |
use custom parser, replaces default (posthtml-parser) |
| options.render | function |
use custom render, replaces default (posthtml-render) |
| options.skipParse | Boolean |
disable parsing |
| options.directives | Array |
Adds processing of custom directives. |
PostHTML Instance
Kind: global variable
Properties
| Name |
|---|
| plugins |
| options |