How to use the initHighlightingOnLoad function from highlight.js
Find comprehensive JavaScript highlight.js.initHighlightingOnLoad code examples handpicked from public code repositorys.
90 91 92 93 94 95 96 97 98 99
<script type="text/javascript"> hljs.tabReplace = ' '; // 4 spaces // ... or hljs.tabReplace = '<span class="indent">\t</span>'; hljs.initHighlightingOnLoad(); </script> ``` ## Custom initialization
5 6 7 8 9 10 11 12 13 14 15
// This function will run for every page once loaded (script is deffered) const common = () => { // Highlight.js // Highlight source code snippets hljs.configure({ languages: [] }); // Do not try to guess the language hljs.initHighlightingOnLoad(); // Highlight code // Lozad // Lazy load images (when they enter the viewport) window.observer = lozad();
GitHub: hechuanhua/blog
9 10 11 12 13 14 15 16 17 18 19 20 21
var renderer = new marked.Renderer() if(typeof window != 'undefined'){ window.onload=function(){ hljs.initHighlightingOnLoad() } } renderer.code = function(code, lang) {
GitHub: Calvein/sydcss-20140206
![Calvein profile picture](/Calvein.png?size=40)
46 47 48 49 50 51 52 53 54
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none // Optional libraries used to extend on reveal.js dependencies: [ { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }, { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, ] }); }
+ 3 other calls in file
highlight.js.highlight is the most popular function in highlight.js (665 examples)