mapbox / rehype-prism

rehype plugin to highlight code blocks in HTML with Prism (via refractor)
MIT License
178 stars 24 forks source link

Register alias support #6

Closed Kikobeats closed 3 years ago

Kikobeats commented 5 years ago

Hello,

The library uses internally refractor for matching with Prism languages and alias.

If the code block has a language alias not supported by refractor, then it throws an error:

Unknown language: `sh` is not registered Register alias support

Since an alias is a very common behavior (for example, on GitHub highlight, sh is an alias for bash), could be useful support registering some alias in order to avoid throwing a global exception.

For doing that, first, need to be supported on refractor level and then be possible to pass the customization throw the module API.

Related: https://github.com/wooorm/refractor/issues/20

ElMassimo commented 3 years ago

It seems that refractor now supports this, so it would only require receiving an alias option and calling refractor.alias.

@katydecorah @silvenon Would you accept a PR implementing this feature request?