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

BUG / FR / documentation: prism loading - possibility to load other languages; other prism components; #47

Open hidegh opened 3 years ago

hidegh commented 3 years ago

When adding the plugin and trying extending languages, only a few are available. Later on other languages will be accessible.

This is IMO a bug.

Adding new languages - init should be called after all other languages are loaded by the plugin (or prismjs)

Features I miss (some might just need documentation to be added):

    eleventyConfig.addPlugin(syntaxHighlight, {
        init: function({ Prism }) {

            Prism.languages.console = Prism.languages.extend('markup', {});
            Prism.languages.terminal = Prism.languages.extend('markup', {});
            console.log('init', Object.keys(Prism.languages))
        }
    });
init [
  'extend',   'insertBefore',
  'DFS',      'markup',
  'html',     'mathml',
  'svg',      'xml',
  'ssml',     'atom',
  'rss',      'css',
  'clike',    'javascript',
  'js',       'console',
  'terminal'
]

Later on languages include more: ruby,rb,yaml,yml,markdown,md,liquid,bash,shell,java,python,py

But still missing: cs, sql, ...

edwardhorsford commented 10 months ago

Came here for similar. I'm attempting to alias nunjucks to jinja2 or twig or django, and this seemed the appropriate way. However if I log the keys of Prism.languages a variable amount are output each time.

vrugtehagel commented 3 months ago

This would also great for using css-extras, since it is not itself a language but rather enhances css. In other words, you cannot autoload css-extras, and so you'd want to be able to specify it manually in your config.