Replies: 2 comments
-
For now I've switched to this approach, and it works, but I don't love it. Monkeypatching always has a bit of code smell to me... But in case anyone else has the same problem and was looking for an immediate solution, this leaves the existing markdown pipeline in place so the content gets processed first, but then the actual rendering is just swapped out from module.exports = (eleventyConfig) => {
eleventyConfig.amendLibrary("md", (lib) => {
lib.render = (src, env) => {
return customMarkdownProcessing(src, env);
}
});
// just so the log label indicates that there's some custom stuff happening
eleventyConfig.addExtension("md", { name: "custom-md" });
} Very open to more 11ty-esque solutions. |
Beta Was this translation helpful? Give feedback.
-
Further followup: I went ahead and wrapped this in a plugin in case anyone else is ever silly enough to want to do this... In my case it was swapping out the Markdown renderer for Pandoc which I can't imagine is too common a desire, but hey, here you go. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to override the Markdown processing with a whole separate engine, using the
addExtension
functionality, and it works well, except that I'd like to be able to use shortcodes inside the Markdown. When I override themd
extension, though, it looks like I also lose the step where the Markdown itself is processed with the specifiedmarkdownTemplateEngine
before being rendered.A minimal reproduction:
example.md
.eleventy.js
As it stands, the correct HTML is generated:
But if I swap which lines are commented in
.eleventy.js
so that it's just returning the raw markdown, it does so, but without the shortcode being processed.I've started diving into the code to figure out how to get at it manually... the built-in Markdown engine's
compile
function has a tantalizingpreTemplateEngine
parameter, but it doesn't seem like I can easily get at that from the user side.This feels like I'm missing something obvious here, so maybe I'm just not looking at the right spot in the documentation. Any help?
Beta Was this translation helpful? Give feedback.
All reactions