Sha256: bdaf9cb43131da61ea47018e24353617cb8b4a3cbaafb31953ed4fdd958b3478

Contents?: true

Size: 931 Bytes

Versions: 7

Compression:

Stored size: 931 Bytes

Contents

require 'webgen/websiteaccess'
require 'webgen/tag'

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 & 2 rubygems

Version Path
gettalong-webgen-0.5.4.20080929 lib/webgen/tag/coderay.rb
gettalong-webgen-0.5.5.20081001 lib/webgen/tag/coderay.rb
webgen-0.5.3 lib/webgen/tag/coderay.rb
webgen-0.5.1 lib/webgen/tag/coderay.rb
webgen-0.5.4 lib/webgen/tag/coderay.rb
webgen-0.5.2 lib/webgen/tag/coderay.rb
webgen-0.5.5 lib/webgen/tag/coderay.rb