You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All of these problems come from the fact that Prism instances have no control over their languages/plugins.
This issue proposes a new API to add languages and plugins that can be used to solve all of the above-mentioned problems.
Description
Instead of adding languages/plugins directly to Prism.{languages,plugins}, new functions Prism.{languages,plugins}.add will be used. The add functions will take 3 pieces of information:
The id of the language/plugin.
A function created the language/plugin.
Optional meta information such as aliases.
The add functions will do 3 things:
Add meta information and the function creating the language/plugin to an internal (or public?) registry.
Run the creator function to actually add the language.
Add aliases (if any).
API
/** * @param id The id of the language/plugin. * @param meta Information about the language/plugin. * @param createFn A function that add the language/plugin to the given Prism instance. */Prism.{languages,plugins}.add(id: string,meta: Meta,createFn: (Prism: Prism)=>void): void;interfaceMeta{/** * A list of aliases of the current language/plugin. */alias?: string|string[];}
Motivation
Right now, Prism has a few problems with how languages and plugins are added/loaded. To list a few of those problems in no particular order:
Prism.languages
andPrism.plugins
namespaces.All of these problems come from the fact that Prism instances have no control over their languages/plugins.
This issue proposes a new API to add languages and plugins that can be used to solve all of the above-mentioned problems.
Description
Instead of adding languages/plugins directly to
Prism.{languages,plugins}
, new functionsPrism.{languages,plugins}.add
will be used. Theadd
functions will take 3 pieces of information:The
add
functions will do 3 things:API
Usage
Note that this usage pattern is very compatible with the current way languages/plugins are added.
Advantages
Disadvantages
The text was updated successfully, but these errors were encountered: