Reputation: 11
I have Laravel project (similar to tech blog site) and i want to use highlightjs
on my website, i have followed their tutorial and linked highlight.pack.js
and my wanted CSS to my website, so i went ahead to try it on my website and created an article, and tried the following code;
<pre>
<code class="html">
<input type="text" name="test" id="test" value="">
</code>
</pre>
But it does not highlight it, it just treats it as a text. What can be the issue of it? I can provide live website if it's needed.
Upvotes: 0
Views: 1228
Reputation: 1142
Did you call initHighlightingOnLoad()
?
If you want to initialize it manually, just add this where you want to highlight something.
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
The CDN-hosted package doesn't have all the languages. If you don't see the language you need in the "Common" section, it can be added manually:
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/go.min.js"></script>
Upvotes: -2