Closed sourabhv closed 4 years ago
refractor
inherits from Prism, so you should be able to change the instance to overwrite methods.
I’m not sure how exactly you’d want to implement this? What does this solve that you can’t already do (each syntax is a function that is given an instance, and if it has dependencies, then it calls register
on that instance with them).
I don't import Prism this way var Prism = require('prismjs/components/prism-core')
prismjs/components/prism-core
doesn't exist
What? I’m sorry, I don’t understand.
Nevermind. Changing the prototype worked
Instead of
import cppLang from 'refractor/lang/cpp';
cppLang(Prism);
Which threw
Unhandled JS Exception: TypeError: Prism.register is not a function. (In 'Prism.register(refractorC)', 'Prism.register' is undefined)
I changed it to
Object.setPrototypeOf(refractor, Prism);
refractor.register(cppLang);
Hi
We use this library to add language support to a custom version of Prism.
Right now we're using
refractor/lang/<lang>
methods directly but that does't work for languages that use.register
method defined on Refractor instance.It'd be great if there was a way to pass Prism instance so
.register
works.Unless this is already possible, I can work on this, if you are open to merging in something like this.