Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: Using plugins with the gulp task? #4

Closed
caraya opened this issue Dec 11, 2016 · 5 comments
Closed

QUESTION: Using plugins with the gulp task? #4

caraya opened this issue Dec 11, 2016 · 5 comments

Comments

@caraya
Copy link

caraya commented Dec 11, 2016

I'm using the following task.

gulp.task('markdown', function() {
  gulp.src('./src/md-content/*.md')
    .pipe(markdown({
      preset: 'commonmark',
      xhtmlOut: true,
      linkify: true,
      typographer: true,
      plugins: [ MARKDOWNIT_PLUGINS ]
    }))
    .pipe(gulp.dest("./src/html-content"));
});

MARKDOWN_PLUGINS is a variable that contains all the plugins I want to use

const MARKDOWNIT_PLUGINS = [
  'markdown-it-anchor',
  'markdown-it-table-of-contents',
  'fa-tool',
  'markdown-it-attrs',
  'markdown-it-abbr',
  'markdown-it-task-lists',
  'markdown-it-implicit-figures',
  'markdown-it-kbd',
  'markdown-it-footnote',
  'markdown-it-block-embed',
  'markdown-it-prism',
  'markdown-it-katex'
];

The task runs successfully but none of the plugins seems to be running. I can't get the expected results from the plugins. Implicit figures doesn't render as expected among other issues I'm finding.

Am I using the plugins correctly? If not what should I use to get these plugins working?

@tom-wolfe
Copy link

I know this is 9 months too late, but in case anybody else has the same problem, in your code, the variable MARKDOWNIT_PLUGINS is already an array. Passing it as plugins: [ MARKDOWNIT_PLUGINS ] just nests that array inside another one. You should use plugins: MARKDOWNIT_PLUGINS instead.

@caraya caraya closed this as completed Aug 5, 2017
@caraya
Copy link
Author

caraya commented Aug 5, 2017

I reinstalled everything, reinstalled markdown-it, reinstalled the plugins, made sure that the code references the array without nesting and now I get the following error

[16:35:57] TypeError: plugin.apply is not a function
    at MarkdownIt.use (/Users/carlos/code/starter/node_modules/gulp-markdown-it/node_modules/markdown-it/lib/index.js:470:10)
    at markdownItPlugin (/Users/carlos/code/starter/node_modules/gulp-markdown-it/index.js:30:10)
    at Gulp.gulp.task (/Users/carlos/code/starter/gulpfile.js:86:11)
    at module.exports (/Users/carlos/code/starter/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/carlos/code/starter/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/carlos/code/starter/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/carlos/code/starter/node_modules/orchestrator/index.js:134:8)
    at Gulp.<anonymous> (/Users/carlos/code/starter/node_modules/gulp/index.js:36:18)
    at Gaze.<anonymous> (/Users/carlos/code/starter/node_modules/glob-watcher/index.js:18:14)
    at emitTwo (events.js:106:13)
    at Gaze.emit (events.js:191:7)
    at Gaze.emit (/Users/carlos/code/starter/node_modules/gaze/lib/gaze.js:129:32)
    at /Users/carlos/code/starter/node_modules/gaze/lib/gaze.js:415:16
    at StatWatcher._pollers.(anonymous function) (/Users/carlos/code/starter/node_modules/gaze/lib/gaze.js:326:7)
    at emitTwo (events.js:106:13)
    at StatWatcher.emit (events.js:191:7)
    at StatWatcher._handle.onchange (fs.js:1501:10)

@caraya caraya reopened this Aug 5, 2017
@tom-wolfe
Copy link

Looking at the stack trace, that's an issue with one of the plugins you're using.

I'd recommend disabling the plugins, then re-enabling them one-by-one until it breaks so you can figure out which one. It's also worth checking the versions of each plugin you're using.

I searched the error message and found this issue referenced in the markdown-it-anchor plugin, so maybe try to disable that one first. If not, it could be one of the other plugins has the same or similar bug.

@caraya
Copy link
Author

caraya commented Aug 6, 2017

Again, thanks for your help. Removing the plugin solved the problem.

The version installed via NPM is ancient. I've asked in the issue if the plugin is still being released in NPM or not.

There are other issues with gulp-markdown-it. It uses markdown-it 4.x instead of the current 8.x. I may have to revert back to remarkable if it continues being an issue.

@tom-wolfe
Copy link

No worries! Glad to be of assistance.

As you've had no response from the author, I feel less guilty pointing you toward my own gulp task for markdown-it: https://github.com/trwolfe13/gulp-markdownit. I made it after I couldn't get this one to work as I needed.

It functions almost the same as this one, with the difference that it doesn't rely on a specific version of markdown-it, and allows more control over plugin initialisation.

@caraya caraya closed this as completed Jun 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants