Trabla: Blogger: code highlight in post without changing template ( using highlight.js )
Solving:
We will use highlight.js to hightlight code in this post.
Official Site: https://highlightjs.org/download/
1. Set HTML mode in Blogger post editor
2. Paste following code
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/default.min.css" rel="stylesheet"></link>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<pre><code class="js">
//A new variable
var v = "aaa";
//The helloWorld Function :)
function helloWorld(){
return "Hello World";
}
</code></pre>
3. Save post and click "Preview" button ( in editor you will not see highlight )
Result:
//A new variable
var v = "aaa";
//The helloWorld Function :)
function helloWorld(){
return "Hello World";
}
No comments:
Post a Comment