Skip to content

Commit

Permalink
feat(index): add parser options {Object} (options.parser)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Dec 27, 2017
1 parent 01a3453 commit dcce8de
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/index.js
Expand Up @@ -105,12 +105,30 @@ class PostHTML {
*/
options = options || {}

if (options.parser) parser = options.parser
if (options.render) render = options.render
if (options.parser) {
if (typeof options.parser === 'object') {
parser = parser(options.parser)
}

if (typeof options.parser === 'function') {
parser = options.parser
}
}
// else {
// TODO(michael-ciniawsky)
// Call parser() with defaults here, when curried
// parser = parser
// }

if (options.render) {
if (typeof options.render === 'function') {
render = options.render
}
}

tree = options.skipParse
? tree
: parser(tree, options)
: parser(tree)

tree.options = options
tree.processor = this
Expand Down

0 comments on commit dcce8de

Please sign in to comment.