1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/doc_config/yard/setup.rb

23 lines
578 B
Ruby
Raw Normal View History

2014-06-20 00:44:06 -04:00
YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/templates')
require 'pygments.rb'
module YARD
module Templates
module Helpers
module HtmlSyntaxHighlightHelper
def html_syntax_highlight_ruby(source)
highlight_with_pygments(:ruby, source)
end
private
def highlight_with_pygments(language, source)
html = Pygments.highlight(source, lexer: language.to_s)
html.sub(%r{\A<div class="highlight">\s*<pre>}, '').sub(%r{</pre>\s*</div>\Z}, '')
end
end
end
end
end