11ty / eleventy-plugin-syntaxhighlight

A pack of Eleventy plugins for syntax highlighting in Markdown, Liquid, and Nunjucks templates.
https://www.11ty.dev/docs/plugins/syntaxhighlight/
MIT License
129 stars 32 forks source link

Add option to load languages explicitly #90

Open vrugtehagel opened 3 months ago

vrugtehagel commented 3 months ago

Resolves https://github.com/11ty/eleventy-plugin-syntaxhighlight/issues/47.

Adds a languages option to force-load languages before the init callback. Minor restructuring has been done to get the plugin in functional format, in order to allow for the init callback to run after the loading of the languages.

Example usage in an .eleventy.js config file:

export default function(eleventyConfig){
    eleventyConfig.addPlugin(SyntaxHighlight, {
        languages: ['css-extras', 'ruby'],
        init: function({Prism}){
            // do stuff with Prism.languages.ruby…
        }
    })
};

PS: The diff looks rather large due to an indentation change; please toggle "hide whitespace" to see the actual changes.

vrugtehagel commented 3 weeks ago

@zachleat is this something you're interested in? Can I do something to get the ball rolling on this one?