Using the highlight.js library within Hype


I’ve imported the highlight.js lib into my Hype project to highlight some JSON that I’ve to an HTML widget. I then created a function that gets fired upon a button click.

highlight.js seems to be getting called OK, but its not hi-lighting the text. I think its something to do with it being an HTML widget.

I’ve attached an example for reference. (70.2 KB)

yes, using a widget aka iFrame is a bad idea here.
also remember to disable “protect from external styles” as highlight.js will come with some css …

Correct; if you just use a normal Rectangle (removing its styling) and choose Edit > Edit Element’s Inner HTML to add your code, then it can be found by the script and color it. (along with unchecking Protect from external styles in the Document Inspector as @h_classen recommends).