Is there a way to parse markdown inside a JSON global data file using liquid?
What I have done in this case is to make a filter that can take the string from JSON and return HTML (remember to mark the return value as safe or html will be stepped out). You can use the same markdown library as 11ty (markdownit if I remember correctly). If you made universal filters before, it is quite easy. If not, I would recommend reading through someone else's plugin to get inspired.
The package is called markdown-it.
Thanks both, using filters with that library looks perfect 馃憣
Wanted to share the filter I ended up using, kudos from #684
// .eleventy.js
module.exports = function(eleventyConfig) {
...
const MarkdownIt = require("markdown-it");
const mdRender = new MarkdownIt();
eleventyConfig.addFilter("renderUsingMarkdown", function(rawString) {
return mdRender.render(rawString);
});
...
}
And in the liquid file
{{ index.rawMarkdown | renderUsingMarkdown }}
Most helpful comment
Wanted to share the filter I ended up using, kudos from #684
And in the liquid file
{{ index.rawMarkdown | renderUsingMarkdown }}