Bas
(Bas van Leeuwen)
2017 年8 月 30 日 14:35
1
Heya,
I’m trying to get the following plugin for Highlight.js to work.
https://github.com/wcoder/highlightjs-line-numbers.js
Problem is that I don’t seem to have access to the hljs object and I am at a total loss as to how Discourse includes the Highlight.js code and styling.
Can anyone give me some pointers?
sam
(Sam Saffron)
2017 年8 月 30 日 23:38
2
It is done via
api.decorateCooked(highlightSyntax)
There is no existing hook to extend highlight js, but you can run decorateCooked in your plugin to apply further transforms to cooked.
Bas
(Bas van Leeuwen)
2017 年8 月 31 日 08:39
3
Thanks, I’ll have a look
Is decorateCooked documented anywhere though? Couldn’t find anything at http://docs.discourse.org
LeoMcA
(Leo McArdle)
2017 年8 月 31 日 14:43
4
Bas
(Bas van Leeuwen)
2017 年8 月 31 日 15:12
5
Yeah, guess that would work
I’ll toy around with this a bit later on and see how to get some javascript to fire on every load