On the lastest blogger theme, you get syntax highlighter of code preinstalled. But if you see your theme does not support code highlighter then this tutorial for you.
To install syntax highlighter fast copy the below cdn then open your blogger dashboard and add this code before the <head> tag.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/styles/default.min.css"/>
Now search for </body> tag then add the below cdn after </body> tag.
<script scr="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/highlight.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
<pre><code>Your Code Here</code></pre>
How to change the style
When you install this syntax highlighter then you see the default look is not good now if you want to change the look of the code box then remove the default.min.css cdn then open www.jsdelivr.com on the browser then search for highlight.js then open the fast result on www.jsdelivr.com now go-to style and choose any style any want then copy the style cdn and paste before the <head> tag.
I am here to use the atelier-cave-dark.css cdn you can use this one see on the below cdn it's the atelier-cave-dark.css CDN.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.2.0/styles/atelier-cave-dark.css"/>
There are one more bonus tips
If you want to add the line number on the code box then follow this part of the tutorial. If you want to add the line number just search for </body> and add the below cdn on before the </body> tag.
<script src="https://cdn.jsdelivr.net/npm/highlightjs-line-numbers.js@2.8.0/src/highlightjs-line-numbers.min.js"></script>
<script>
hljs.initLineNumbersOnLoad();
</script>
Conclosing
After you add this code highlighter if you want to change the style just remove the old css cdn and add the new css style cdn. I hope this article is helpful thanks for with us.
Yyy
ReplyDeleteKya baatvh
ReplyDelete(m)
ReplyDelete