Inactive Project: I am no longer updating this, as I've switched to using embedded Gists for syntax highlighting on my blog
jekyll_prism
Jekyll plugin to add support for prism.js.
Usage
This adds code
blocks and ext_code
tags for syntax highlighting.
code block
The code
block creates the necessary HTML for prism to do its thing:
{% code %}
#!/bin/bash
echo "I'm so cool"
{% endcode %}
You can also pass a language option to set the language used for highlighting:
{% code ruby %}
require 'cool_module'
puts "I'm so cool, for reals"
{% endcode %}
If you're using prism with the line numbers plugin, you can provide line numbers to highlight (use 'all' to highlight all lines):
{% code ruby 1,3 %}
require 'cool_module'
puts "I'm so cool, for reals"
{% endcode %}
ext_code tag
This tag uses the file highlight plugin for prism, and creates an HTML object to include external code:
{% ext_code /path/to/cool/code.rb %}
You can provide language and line number parameters for this as well, just like the code block:
{% ext_code /path/to/cooler/code.rb ruby 1,10-51,77,90 %}
Installation
- Add 'jekyll_prism' to the
gems
array in your _config.yml - Add the prism.js and prism.css files to your site, as described on prism's site
- Note: the ext_code tag uses the File Highlight plugin. If you don't include that, the tags won't work
License
jekyll_prism is released under the MIT License. See the bundled LICENSE file for details.