eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Allow custom markdown engines to access preprocessing engine

Open danburzo opened this issue 2 years ago • 2 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

danburzo avatar Jan 27 '23 14:01 danburzo

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() 🫠

danburzo avatar Jan 28 '23 07:01 danburzo

This seems marginally related to the Render plugin, fwiw: https://www.11ty.dev/docs/plugins/render/

Also worth mentioning https://www.11ty.dev/docs/languages/custom/#overriding-a-built-in-template-language (which is not quite what you were asking for)

zachleat avatar May 28 '24 20:05 zachleat

More recently I would note (for future me or other interested parties) that simple aliases of an existing markdown engine do use the preprocessing engine, as #3339 notes.

Likely this would involve an addition similar to defaultRenderer or might look like #3351.

By default this repo closes enhancement request issues and places them in a queue for folks to upvote. We do this to avoid a large build-up of open issues. We got this idea from the lodash project.

Don’t forget to upvote the first comment with 👍 to register your vote! You can view the current enhancement backlog.

zachleat avatar Jul 05 '24 19:07 zachleat