johno / gulp-remarkable

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

Plugin support? #18

Open caraya opened 3 years ago

caraya commented 3 years ago

@johno Has there been any progress with plugins support as described in #8 ?

The solution in #14 and #15 did not work. The example in the README only covers using the second parameter of gulp-remarkable when using with an included function, not with a third-party plugin.

In the example provides in #14, it is not clear how to support multiple plugins or if those changes were merged into the repository or not.

Here is the code I'm using, my attempt at extrapolating from previous examples:

// Markdown
const markdown = require('gulp-remarkable');
// Remarkable plugins
const admonitions = require('remarkable-admonitions');
const remarkableFigure = require('remarkable-figure-plugin');
const headingId = require('remarkable-plugin-heading-id');
const extLink = require('remarkable-extlink');

gulp.task('markdown', () => {
  const opts = {
    preset: 'commonmark',
    remarkableOptions: {
      typographer: true,
      linkify: true,
      breaks: false,
    },
  };

  return gulp.src('./src/md-content/*.md')
      .pipe(markdown(opts, ((markdown) => {
        markdown.use(admonitions);
        markdown.use(remarkableFigure);
        markdown.use(headingId);
        markdown.use(extLink);
      })))
      .pipe(gulp.dest('./src/html-content'));
});