How to use the highlightAll function from highlight.js

Find comprehensive JavaScript highlight.js.highlightAll code examples handpicked from public code repositorys.

13
14
15
16
17
18
19
20
21
22

```html
<script type="text/javascript" src="/path/to/highlight.min.js"></script>
<script type="text/javascript" src="/path/to/curl.min.js"></script>
<script type="text/javascript">
  hljs.highlightAll();
</script>
```

### Using directly from the UNPKG CDN
fork icon7
star icon6
watch icon7

4
5
6
7
8
9
10
11
12
13
14
    return deald
}
// function highlight() {


// const hljs = require("highlight.js");
// hljs.highlightAll();
// var d = new Date().getTime()
// if (window.performance && typeof window.performance.now === "function") {
//     d += performance.now();
// }
fork icon0
star icon0
watch icon0

2
3
4
5
6
7
8
9
10
11
12
13
14


const highlight = require('highlight.js')


exports.onPreRouteUpdate = ({ location, prevLocation }) => {
  console.log(document.querySelectorAll('code[class]'))
  highlight.highlightAll()
}


exports.onRouteUpdate = () => {
  highlight.highlightAll()
fork icon0
star icon0
watch icon0

10
11
12
13
14
15
16
17
18
19
const {page, flow, content = '', lang, theme} = option

function ui_element(css) {
    const send2Parent = protocol( receive )
    send2Parent({page, from: lang, flow: flow ? `${flow}/${widget}` : widget, type: 'init', filename, line: 15})
    hljs.highlightAll()
    const snippet = hljs.highlightAuto(content).value
    const code = bel`<code class="${css.code} language-${lang} hljs"></code>`
    code.innerHTML = snippet
    const element = bel`<div class=${css.snippet}><pre>${code}</pre></div>`
fork icon0
star icon0
watch icon0