Sha256: 7f7c5979c562d1608a972886de8e53d3e1f6af2243e687de825c44091b70c1c4

Contents?: true

Size: 563 Bytes

Versions: 14

Compression:

Stored size: 563 Bytes

Contents

# encoding: utf-8

require "ace/filters"
require "nokogiri"
require "albino"

module Ace
  class PygmentsFilter < Filter
    def call(item, content)
      doc = Nokogiri::HTML(content)
      doc.css("pre[lang]").each do |pre|
        unless pre['lang'].nil? || pre['lang'].empty?
          # Set $VERBOSE to nil if you don't want to see this message.
          warn "~ Syntax highlight in '#{item.original_path}' using '#{pre['lang']}' lexer."
          pre.replace Albino.colorize(pre.content, pre['lang'])
        end
      end
      doc.to_s
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ace-0.4.9 lib/ace/filters/pygments.rb
ace-0.4.8 lib/ace/filters/pygments.rb
ace-0.4.7 lib/ace/filters/pygments.rb
ace-0.4.6 lib/ace/filters/pygments.rb
ace-0.4.5 lib/ace/filters/pygments.rb
ace-0.4.4 lib/ace/filters/pygments.rb
ace-0.4.3 lib/ace/filters/pygments.rb
ace-0.4.2 lib/ace/filters/pygments.rb
ace-0.4.1 lib/ace/filters/pygments.rb
ace-0.4 lib/ace/filters/pygments.rb
ace-0.3.3 lib/ace/filters/pygments.rb
ace-0.3.2 lib/ace/filters/pygments.rb
ace-0.3.1 lib/ace/filters/pygments.rb
ace-0.3 lib/ace/filters/pygments.rb