# Modifying/using highlight.js

**URL:** https://meta.discourse.org/t/modifying-using-highlight-js/69073
**Category:** Development
**Created:** [August 30, 2017, 2:35pm UTC](https://meta.discourse.org/t/modifying-using-highlight-js/69073 "2017-08-30T14:35:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Bas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bas/32/294929_2.png) [@Bas](https://meta.discourse.org/u/Bas)
#### Post date: [August 30, 2017, 2:35pm UTC](https://meta.discourse.org/t/modifying-using-highlight-js/69073/1 "2017-08-30T14:35:12Z")

</div>

Heya,

I’m trying to get the following plugin for _Highlight.js_ to work.  
[https://github.com/wcoder/highlightjs-line-numbers.js](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?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 30, 2017, 11:38pm UTC](https://meta.discourse.org/t/modifying-using-highlight-js/69073/2 "2017-08-30T23:38:43Z")

</div>

It is done via

```plaintext
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.

---

<div class="post-metadata">

### Author: ![Bas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bas/32/294929_2.png) [@Bas](https://meta.discourse.org/u/Bas)
#### Post date: [August 31, 2017, 8:39am UTC](https://meta.discourse.org/t/modifying-using-highlight-js/69073/3 "2017-08-31T08:39:12Z")

</div>

Thanks, I’ll have a look 🙂

Is decorateCooked documented anywhere though? Couldn’t find anything at [http://docs.discourse.org](http://docs.discourse.org)

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [August 31, 2017, 2:43pm UTC](https://meta.discourse.org/t/modifying-using-highlight-js/69073/4 "2017-08-31T14:43:40Z")

</div>

There’s always the source code 😉

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/plugin-api.js.es6#L93-L107](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/plugin-api.js.es6#L93-L107)

---

<div class="post-metadata">

### Author: ![Bas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bas/32/294929_2.png) [@Bas](https://meta.discourse.org/u/Bas)
#### Post date: [August 31, 2017, 3:12pm UTC](https://meta.discourse.org/t/modifying-using-highlight-js/69073/5 "2017-08-31T15:12:19Z")

</div>

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
