Prism.js - Style your blog's code!
One of the first things I needed to tackle when setting up this blog was syntax highlighting. I knew I would be posting code samples and I needed them to be easy to read and consume.
After a little looking around, I was able to find a very simple to use JavaScript/CSS implementation that will do syntax highlighting for me on the blog. Thanks Prism!
Here is an example!
This was really easy to implement. It took 4 steps.
If you are not interested in customizing your own or don't want to host your own files, you can use a CDN. This site uses the following links for the prism JS and CSS.
That's it! Prism did the rest for me. Now whenever I want syntax highlighting, it is one simple step to do.
After a little looking around, I was able to find a very simple to use JavaScript/CSS implementation that will do syntax highlighting for me on the blog. Thanks Prism!
Here is an example!
var s = 'this is a string';
var obj = {
name: 'Adam',
age: 99,
birthdate: new Date('1/1/1915')
};
This was really easy to implement. It took 4 steps.
- Customize and download prism.js and prism.css from their website. (This is insanely easy to do.)
- Upload the javascript and css files to the website.
- Include the javascript and css files on the website.
- Wrap the code I want highlighted in tags.
If you are not interested in customizing your own or don't want to host your own files, you can use a CDN. This site uses the following links for the prism JS and CSS.
<link href='//cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism-okaidia.css' rel='stylesheet' type='text/css'/>
<script src='//cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/prism.js' type='text/javascript'/>
That's it! Prism did the rest for me. Now whenever I want syntax highlighting, it is one simple step to do.
Comments