Sha256: 2a54e1b4949059a073d1ad204d40feeded7c8c4872be730f418df826c07b72b8

Contents?: true

Size: 905 Bytes

Versions: 7

Compression:

Stored size: 905 Bytes

Contents

# -*- encoding: utf-8 -*-

module Webgen::Tag

  # Provides syntax highlighting via the +coderay+ library.
  class Coderay

    include Webgen::Tag::Base
    include Webgen::WebsiteAccess

    # Highlight the body of the block.
    def call(tag, body, context)
      require 'coderay'
      options = {
        :css => :style,
        :wrap => param('tag.coderay.wrap').to_sym,
        :line_numbers => (param('tag.coderay.line_numbers') ? :inline : nil),
        :line_number_start => param('tag.coderay.line_number_start'),
        :tab_width => param('tag.coderay.tab_width'),
        :bold_every => param('tag.coderay.bold_every')
      }

      if param('tag.coderay.process_body')
        body = website.blackboard.invoke(:content_processor, 'tags').call(context.clone(:content => body)).content
      end
      CodeRay.scan(body, param('tag.coderay.lang').to_sym).html(options)
    end

  end

end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 lib/webgen/tag/coderay.rb
gettalong-webgen-0.5.8.20090507 lib/webgen/tag/coderay.rb
gettalong-webgen-0.5.9.20090620 lib/webgen/tag/coderay.rb
gettalong-webgen-0.5.9.20090626 lib/webgen/tag/coderay.rb
thewoolleyman-webgen-0.5.8.20090419 lib/webgen/tag/coderay.rb
webgen-0.5.7 lib/webgen/tag/coderay.rb
webgen-0.5.8 lib/webgen/tag/coderay.rb