Sha256: 654e9bd4f549fb48641cd2e63a010ec7cc2647fd168d3d0cabde1a0c185c0ea5

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

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

4 entries across 4 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.5.20081010 lib/webgen/tag/coderay.rb
gettalong-webgen-0.5.5.20081012 lib/webgen/tag/coderay.rb
gettalong-webgen-0.5.6.20081020 lib/webgen/tag/coderay.rb
webgen-0.5.6 lib/webgen/tag/coderay.rb