MCPcopy
hub / github.com/posthtml/posthtml / PostHTML

Class PostHTML

lib/index.js:18–244  ·  view source on GitHub ↗

* @author Ivan Voischev (@voischev), * Ivan Demidov (@scrum) * * @requires api * @requires posthtml-parser * @requires posthtml-render * * @constructor PostHTML * @param {Array} plugins - An array of PostHTML plugins

Source from the content-addressed store, hash-verified

16 * @param {Array} plugins - An array of PostHTML plugins
17 */
18class PostHTML {
19 constructor (plugins) {
20 /**
21 * PostHTML Instance
22 *
23 * @prop plugins
24 * @prop options
25 */
26 this.version = pkg.version
27 this.name = pkg.name
28 this.plugins = typeof plugins === 'function' ? [plugins] : plugins || []
29 this.source = ''
30
31 /**
32 * Tree messages to store and pass metadata between plugins
33 *
34 * @memberof tree
35 * @type {Array} messages
36 *
37 * @example
38 * ```js
39 * export default function plugin (options = {}) {
40 * return function (tree) {
41 * tree.messages.push({
42 * type: 'dependency',
43 * file: 'path/to/dependency.html',
44 * from: tree.options.from
45 * })
46 *
47 * return tree
48 * }
49 * }
50 * ```
51 */
52 this.messages = []
53
54 /**
55 * Tree method parsing string inside plugins.
56 *
57 * @memberof tree
58 * @type {Function} parser
59 *
60 * @example
61 * ```js
62 * export default function plugin (options = {}) {
63 * return function (tree) {
64 * tree.match({ tag: 'include' }, function(node) {
65 * node.tag = false;
66 * node.content = tree.parser(fs.readFileSync(node.attr.src))
67 * return node
68 * })
69 *
70 * return tree
71 * }
72 * }
73 * ```
74 */
75 this.parser = parser

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…