11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow custom markdown engines to access preprocessing engine

danburzo opened this issue · comments

Is your feature request related to a problem? Please describe.

I'm trying to replace markdown-it with remark, and the docs currently state:

Note that overriding md opts-out of the default pre-processing by another template language of Markdown Files.

Describe the solution you'd like

It would be great if we had access to the Liquid/Nunjucks/etc. pre-processing to make a fully-fledged replacement.

Describe alternatives you've considered

Mimicking the this.mdLib API like florianeckerstorfer/eleventy-plugin-remark is currently doing.

Additional context

No response

For a Nunjucks-specific workaround, you can promisify the event to wait for, and obtain, a reference to the library and associated environment:

const njk = new Promise(resolve => {
  config.events.on('eleventy.engine.njk', payload => resolve(payload));
});

Later edit: due to Node's architecture you can't reliably await njk in compile() 🫠