all repos — h3rald @ 7b2a3fc075194335a2c7171cdbce0fa350be41fe

The sources of https://h3rald.com

Added code highlighting support (CodeRay).
h3rald h3rald@h3rald.com
Mon, 13 Sep 2010 14:41:16 +0200
commit

7b2a3fc075194335a2c7171cdbce0fa350be41fe

parent

a2e7e211cc571a84a09ce940b3f4f4fa0d8fa620

3 files changed, 55 insertions(+), 6 deletions(-)

jump to
A content/styles/_code.scss

@@ -0,0 +1,51 @@

+.code { + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + background-color: #222; + font-family: 'Courier New', 'Terminal', monospace; + color: #E6E0DB; + padding: 20px; + overflow: auto; + font-size: 12px; + margin: 20px 0 20px 0; + pre { + line-height: 1.2em; + margin: 0px; + padding: 0px; } + .no { + font-weight: bold; + color: #595959; + } + .an { + color: #E7BE69; } + .c { + color: #BC9358; + font-style: italic; } + .ch { + color: #509E4F; } + .cl, .co { + color: #FFF; } + .fl { + color: #A4C260; } + .fu { + color: #FFC56D; } + .gv { + color: #D0CFFE; } + .i { + color: #A4C260; } + .il {} + .iv { + color: #D0CFFE; } + .pp { + color: #E7BE69; } + .r { + color: #CB7832; } + .rx, .s { + color: #A4C260; } + .sy { + color: #6C9CBD; } + .ta { + color: #E7BE69; } + .pc { + color: #6C9CBD; } }
M content/styles/style.scsscontent/styles/style.scss

@@ -5,3 +5,4 @@ @import "_content.scss";

@import "_fancybox.scss"; @import "_fancybox-gallery.scss"; @import "_vendor.scss"; +@import "_code.scss";
M lib/highlighter.rblib/highlighter.rb

@@ -1,18 +1,15 @@

- # Monkey patch Nanoc::Helpers::Filtering +require 'coderay' module Nanoc3::Helpers::Filtering def highlight(syntax, &block) - # Seamlessly ripped off from the filter method... - # Capture block data = capture(&block) # Reconvert <% %> data.gsub! /&lt;%/, '<%' data.gsub! /%&gt;/, '%>' - # Filter captured data - filtered_data = "\n<notextile>"+Albino.colorize(data, syntax)+"</notextile>\n" rescue data - # Append filtered data to buffer + filtered_data = CodeRay.scan(data.strip, syntax).div(:line_numbers => :inline, :tab_width => 2, :css =>:class) + filtered_data = "<notextile>\n"+filtered_data+"\n</notextile>" buffer = eval('_erbout', block.binding) buffer << filtered_data end