wooorm / refractor

Lightweight, robust, elegant virtual syntax highlighting using Prism
MIT License
724 stars 35 forks source link

Add support for checking if a syntax is registered #6

Closed conorhastings closed 7 years ago

wooorm commented 7 years ago
  1. why is it needed?
  2. could you add docs (edit: done!) and tests?
  3. Prism uses different terms compared to highlight.js (e.g., register instead of registerLanguage), so we could use language or syntax or something else here too, what do you think?
conorhastings commented 7 years ago

@wooorm added tests

in regards to your first question, I'd like a way to know if syntax has been previously registered or not.

conorhastings commented 7 years ago

@wooorm updated with tests and coverage passing

conorhastings commented 7 years ago

@wooorm fixed example

wooorm commented 7 years ago

This looks great!

One more Q, while I was in the process of merging this: the result of syntax isn’t useful at all to other people I think. How about a registered function instead, that returns a boolean: whether the given language is registered?

Does that solve your problem?

conorhastings commented 7 years ago

@wooorm yeah would actually prefer that, just was matching lowlight as much as possible, but i'll update to that

wooorm commented 7 years ago

Don’t worry, I’ll do it, I was half way through merging this already!

conorhastings commented 7 years ago

@wooorm sounds good, thanks!

wooorm commented 7 years ago

Released!

conorhastings commented 7 years ago

@wooorm awesome! thanks!