eleventy
eleventy copied to clipboard
Allow `addMarkdownHighlighter` to be overridden at the Project level (not just Plugin)
I was trying to do unique-to-my-project highlighter overrides--without the overhead of creating another plugin (because some of my changes are currently very idiosyncratic...)--but found that addMarkdownHighlighter() would mysteriously not be called unless it was in a plugin's .eleventy.js rather than a project-level one.
That fact was clarified by this code: https://github.com/11ty/eleventy/blob/ecd0579a2dded6939510b7c23841388b26eb6d16/src/UserConfig.js#L134-L139
However, that points to overriding the Markdown library...or passing it options...neither of which address the sort of conditional markup output I'd want to provide for customLanguage or whatever in my project.
The basic code for what I was attempting exists in https://github.com/KevinGimbel/eleventy-plugin-mermaid/blob/main/.eleventy.js#L13-L21 but attempting to customize that in my project failed (because of the above).
I'd love to avoid forking a plugin just to add project specific features.
Please consider adding addMarkdownHighlighter() to the main config options.
Thanks! 🎩
I think using addMarkdownHighlighter() on a project level is not recommended, not documented and discouraged in the code.
You should probably just amend the library instead like documented here: https://www.11ty.dev/docs/languages/markdown/#optional-amend-the-library-instance
I did this in my blog to use shiki as a highlighter and described it here: https://www.hoeser.dev/blog/2023-02-07-eleventy-shiki-simple/