Module: Webgen::Tag::Coderay
- Defined in:
- lib/webgen/tag/coderay.rb
Overview
Provides syntax highlighting via the coderay
library.
Class Method Summary collapse
-
.call(tag, body, context) ⇒ Object
Highlight the body of the block.
Class Method Details
.call(tag, body, context) ⇒ Object
Highlight the body of the block.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webgen/tag/coderay.rb', line 12 def self.call(tag, body, context) config = context[:config] = {} if config['tag.coderay.css'].to_s == 'other' [:css] = :class elsif config['tag.coderay.css'].to_s == 'class' [:css] = :class context.html_head.link_file(:css, '/stylesheets/coderay-default.css') else [:css] = :style end .merge!(:wrap => config['tag.coderay.wrap'].to_sym, :line_numbers => (config['tag.coderay.line_numbers'] ? :inline : nil), :line_number_start => config['tag.coderay.line_number_start'], :tab_width => config['tag.coderay.tab_width'], :bold_every => config['tag.coderay.bold_every']) if config['tag.coderay.process_body'] body = context.website.ext.content_processor.call('tags', context.clone(:content => body)).content end CodeRay.scan(body, config['tag.coderay.lang'].to_sym).html() end |