Posts

Showing posts from May, 2019

Code Syntax Highlighting

Image
Code Syntax Highlighting If you have a site which has code snippets, you probably want to implement code syntax highlighting. How do you implement syntax highlighting? You can easily implement a solution in a few minutes using hightlight.js . Within your HTML page(s) head tag, you will need to add the below three lines of code. The three lines of code import the required css, import the required JavaScript functions and initializes the JavaScript object. <!-- Syntax Highlighting --> <link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css' rel='stylesheet'/> <script src='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js'/> <script>hljs.initHighlightingOnLoad();</script> If you are using a tool like Blogger or WordPress you will need to add the three lines of code to your template. In Blogger it should look something like this: After you implement the previous three lines