Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to pass custom Prism plugins #4

Closed
mathiasbynens opened this issue Sep 12, 2018 · 5 comments
Closed

Make it possible to pass custom Prism plugins #4

mathiasbynens opened this issue Sep 12, 2018 · 5 comments
Milestone

Comments

@mathiasbynens
Copy link
Contributor

Can haz a way to pass custom Prism plugins to this 11ty plugin? Maybe this can be solved generically by allowing something like this in 11ty's plugin system:

-eleventyConfig.addPlugin(syntaxHighlight);
+eleventyConfig.addPlugin(syntaxHighlight, initializer);

For this particular plugin, initializer would be a function that gets called with the Prism object as an argument. Users could then do something like:

const initializer = (Prism) => {
  Prism.languages.myCustomLanguage = /* */;
};
eleventyConfig.addPlugin(syntaxHighlight, initializer);

What do you think?

@zachleat
Copy link
Member

I think that’s a good idea, yeah. 👍

Maybe the this inside the callback should be the eleventyConfig object too?

@mathiasbynens
Copy link
Contributor Author

Sounds good to me!

@zachleat
Copy link
Member

I’m thinking plugins may want to expose multiple initializer arguments…

Any recommendations stylistically on ({ Prism, otherThing }) vs (Prism, otherThing)?

I think I like the latter better as it doesn’t seem to be as tightly coupled to the upstream plugin’s variable naming. The drawback there is that it has strict argument order ¯_(ツ)_/¯

@mathiasbynens
Copy link
Contributor Author

I strongly prefer ({ Prism, otherThing }). Variable naming is part of the plugin’s API design.

@zachleat
Copy link
Member

https://github.com/11ty/eleventy-plugin-syntaxhighlight#options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants