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
Motivation
When adding language-specific hooks the first line of the callback function is usually the language check. The problem here is that every language-specific hook has to know all the aliases of the target language.
For languages like Markup, this is quite a number of even for languages with just one alias this can cause problems.
Description
To solve this, we could add a function like this:
aliasMap is just a private variable which does what the name suggests. We would then use the map here and here to resolve the aliases for our hooks.
The class name of highlighted elements remains unchanged. (Or should we resolve this as well?)
Alternative
We could also use the order of the entries in Prism.languages. Aliases are always added after the language definition. This means that we can resolve aliases by looking for the first key in Prism.languages with the same value.
A bit hacky but we wouldn't have to change any of the existing language definitions.
Edit: Added alternative
The text was updated successfully, but these errors were encountered:
Motivation
When adding language-specific hooks the first line of the callback function is usually the language check. The problem here is that every language-specific hook has to know all the aliases of the target language.
For languages like Markup, this is quite a number of even for languages with just one alias this can cause problems.
Description
To solve this, we could add a function like this:
aliasMap
is just a private variable which does what the name suggests. We would then use the map here and here to resolve the aliases for our hooks.The class name of highlighted elements remains unchanged. (Or should we resolve this as well?)
Alternative
We could also use the order of the entries in
Prism.languages
. Aliases are always added after the language definition. This means that we can resolve aliases by looking for the first key inPrism.languages
with the same value.A bit hacky but we wouldn't have to change any of the existing language definitions.
Edit: Added alternative
The text was updated successfully, but these errors were encountered: