Closed caraya closed 2 years ago
It's not tied to marked. Just pass a different renderer to the register function as stated in the readme.
The reason why I ask is that I tried it with Markdown-it and it did not work but when I switch to Marked, it does. That's why having a working example with a different parser and made it work would be very helpful. It would also help me to try and isolate if the problem is with this plugin or with the renderer.
I tried it with gulp-nunjuks and gulp-nunjucks-render as the rendererer and it didn't work with either of them.
The register function expects a function that takes markdown as a string and returns html as a string. I've never used Markdown-it, but from the readme I imagine it's something like...
var nunjucks = require('nunjucks'),
markdown = require('nunjucks-markdown'),
md = require('markdown-it')();
var env = nunjucks.configure('views');
markdown.register(env, md.render);
// or
markdown.register(env, text => md.render(text));
If the first line doesn't work, use the second.
The parser works but I'm getting different errors depending on the plugin I use:
If I use gulp-nunjuck
's compile method, it renders the plugin with undefined whenever I use markdown in the content, but it renders fine if I use HTML
if I use gulp-markdown-render
then I geet this error:
[08:03:43] Template render error in plugin "gulp-nunjucks"
Message:
(unknown path) [Line 3, Column 4]
unknown block tag: markdown
Details:
fileName: /Users/carlos/code/static-gen-njk/src/pages/css-containment.md
domainEmitter: [object Object]
domainThrown: false
So the problem doesn't appear to be with this plugin, at least not directly. Thanks for helping me troubleshoot
I gotcha. I haven't really actively worked on this plugin in a long time, so it's not without reason that some things need to be updated. As you say though, that seems non-related. If you learn otherwise let me know and I'll see what I can do to fix it.
I'm trying to get
nunjucks-markdown
to work withgulp-nunjucks-renderer
andmakrdown-it
instead of Marked. I would use examples if any where available. They all seem to be based on Marked so whoever wants to use a different parser is on his own.Does anyone have a working example of using
nunjucks-markdown
withmarkdown-it
or another parser?