Sha256: 9055d24fc9b1c905e254ae145ef048beb5df2ed68e618e2e2e5263622b430474

Contents?: true

Size: 1.25 KB

Versions: 18

Compression:

Stored size: 1.25 KB

Contents

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

webgen_require 'coderay'

module Webgen
  class Tag

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

      # Highlight the body of the block.
      def self.call(tag, body, context)
        config = context[:config]

        options = {}
        if config['tag.coderay.css'].to_s == 'other'
          options[:css] = :class
        elsif config['tag.coderay.css'].to_s == 'class'
          options[:css] = :class
          context.html_head.link_file(:css, '/stylesheets/coderay-default.css')
        else
          options[:css] = :style
        end
        options.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(options)
      end

    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
webgen-1.7.3 lib/webgen/tag/coderay.rb
webgen-1.7.2 lib/webgen/tag/coderay.rb
webgen-1.7.1 lib/webgen/tag/coderay.rb
webgen-1.7.0 lib/webgen/tag/coderay.rb
webgen-1.6.0 lib/webgen/tag/coderay.rb
webgen-1.5.2 lib/webgen/tag/coderay.rb
webgen-1.5.1 lib/webgen/tag/coderay.rb
webgen-1.5.0 lib/webgen/tag/coderay.rb
webgen-1.4.1 lib/webgen/tag/coderay.rb
webgen-1.4.0 lib/webgen/tag/coderay.rb
webgen-1.3.0 lib/webgen/tag/coderay.rb
webgen-1.2.1 lib/webgen/tag/coderay.rb
webgen-1.2.0 lib/webgen/tag/coderay.rb
webgen-1.1.0 lib/webgen/tag/coderay.rb
webgen-1.0.0 lib/webgen/tag/coderay.rb
webgen-1.0.0.beta3 lib/webgen/tag/coderay.rb
webgen-1.0.0.beta2 lib/webgen/tag/coderay.rb
webgen-1.0.0.beta1 lib/webgen/tag/coderay.rb