all repos — h3rald @ 0c274d4c8d5ee1e2cba9c9f9c412462a7b518399

The sources of https://h3rald.com

lib/highlighter.rb

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
# Monkey patch Nanoc::Helpers::Filtering
#require 'coderay'

module Nanoc3::Helpers::Filtering

	def highlight(syntax, &block)
		data = capture(&block).strip
		# Reconvert <% %>
    data.gsub! /</, '&lt;'
    data.gsub! />/, '&gt;'
		data.gsub! /&lt;%/, '<%'
		data.gsub! /%&gt;/, '%>'
		#filtered_data = CodeRay.scan(data.strip, syntax).div(:line_numbers => :inline, :tab_width => 2, :css =>:class)
		filtered_data = "<notextile>\n<div class='#{syntax}'><pre><code>\n"+data+"\n</code></pre></div></notextile>"
		buffer = eval('_erbout', block.binding)
		buffer << filtered_data
	end

end

include Nanoc3::Helpers::Filtering