johno / gulp-remarkable

A gulp wrapper for the remarkable markdown parser (CommonMark spec).
MIT License
10 stars 3 forks source link

Adds 2nd parameter for calling function to modify Remarked Instance #15

Closed EvansJahja closed 6 years ago

EvansJahja commented 7 years ago

2nd parameter fnConfigureMd is expected to be a function that receives the Remarked instance.

Do whatever you want with md there synchronously

EvansJahja commented 7 years ago
Usage example: Adding plugins
return gulp.src(globMarkdown)
    .pipe(markdown(opts, (md=>{
      md.renderer.rules.heading_open = headingAnchorRendererPlugin
    })))

function headingAnchorRendererPlugin(tokens, idx ) {
  if (tokens[idx+1].type == 'inline') {
    let heading_anchor = slug(tokens[idx+1].content, {lower: true})
    return '<h' + tokens[idx].hLevel + ' id="' + heading_anchor + '">';
  }
  return '<h' + tokens[idx].hLevel + '>';
}
EvansJahja commented 7 years ago

@johnotander @charlike Any comments?

johno commented 6 years ago

Sorry for the delay @Charon77. This lgtm, do you mind adding a bit of documentation to the readme? Then I'll get this merged and published.

derhuerst commented 6 years ago

@Charon77 friendly ping (:

EvansJahja commented 6 years ago

Ah sorry, I must have missed the notif and didn't see the comments here.

I'll sure do, will keep you posted

EvansJahja commented 6 years ago

@johno Is this alright?

johno commented 6 years ago

This is great, thanks!