Skip to content

Instantly share code, notes, and snippets.

@sentientwaffle
Created February 7, 2012 20:53
Show Gist options
  • Save sentientwaffle/1761883 to your computer and use it in GitHub Desktop.
Save sentientwaffle/1761883 to your computer and use it in GitHub Desktop.
Jekyll plugin for syntax highlighting via stratus-color
require 'shellwords'
module Jekyll
class StratusColorBlock < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@lang = markup
end
def render(context)
code = super
code.gsub! /\n[ ]{4}/, "\n"
code.strip!
code = Shellwords.escape code
`echo #{code} | stratus-color -l #{@lang} -N`.gsub! "<li></li></ul>", "</ul>"
end
end
end
Liquid::Template.register_tag('color', Jekyll::StratusColorBlock)
.stratus-color {
font-family: monospace;
font-size: 13px;
overflow: auto;
white-space: pre;
word-wrap: normal;
}
.stratus-color > ul {
float: left;
list-style: none;
}
.stratus-color > ul li {
height: 15px;
padding-left: 2px;
}
.stratus-color > .stratus-color-gutter {
float: left;
padding: 0px 3px 0px 6px;
text-align: right;
-webkit-user-select: none;
}
.stratus-color > .stratus-color-gutter > span {
display: block;
}
.stratus-color::-webkit-scrollbar {
height: 10px;
width: 10px;
}
.stratus-color::-webkit-scrollbar-track {
background: #eee;
box-shadow: inset 1px 1px 2px rgba(0,0,0,0.20);
}
.stratus-color::-webkit-scrollbar-thumb {
background: #888;
box-shadow: inset 1px 0px 2px rgba(0,0,0,0.20);
}
.stratus-color::-webkit-scrollbar-thumb:hover {
background: #666;
box-shadow: inset 1px 1px 3px rgba(0,0,0,0.20);
}
.stratus-color {
background: #323232;color: white; }
.stratus-color *::selection {
background: rgba(90, 100, 126, 0.35); }
.stratus-color li::selection {
background: rgba(90, 100, 126, 0.35); }
.stratus-color-gutter {
background: #f4f4f4;color: #888; }
.stratus-color-gutter > span.current-middle {
background: #fff;border-color: #ccc; }
.stratus-color-gutter > span.current-top {
border-width: 1px 0px 0px;
border-style: solid;
margin: -1px 0px 0px;
background: #fff;border-color: #ccc; }
.stratus-color-gutter > span.current-bottom {
border-width: 0px 0px 1px;
border-style: solid;
margin: 0px 0px -1px;
background: #fff;border-color: #ccc; }
.stratus-color-gutter > span.current {
border-width: 1px 0px;
border-style: solid;
margin: -1px 0px;
background: #fff;border-color: #ccc; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment