Sha256: 353279da509febdb2c70dd285c5fa41ad6c924825700f573494e8beb5e5abb14

Contents?: true

Size: 468 Bytes

Versions: 4

Compression:

Stored size: 468 Bytes

Contents

# This is a strictly optional dependency.
begin
  require "pygments"
rescue LoadError => e
  # Optional dependency.
end

module RailsBlogEngine::Filters
  # Syntax highlighting for code blocks.
  class Code < Base
    register_filter :code

    def process(text, options)
      if defined?(Pygments)
        Pygments.new(text, options[:lang] || 'ruby').colorize
      else
        raise "Install pygments-gem to enable syntax highlighting"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_blog_engine-0.0.4 lib/rails_blog_engine/filters/code.rb
rails_blog_engine-0.0.3 lib/rails_blog_engine/filters/code.rb
rails_blog_engine-0.0.2 lib/rails_blog_engine/filters/code.rb
rails_blog_engine-0.0.1 lib/rails_blog_engine/filters/code.rb