Sha256: 04471a4b4478d5dbf6e936957ab69e1f08aea9377e91fd19a3e8bdecca68b0e5

Contents?: true

Size: 504 Bytes

Versions: 2

Compression:

Stored size: 504 Bytes

Contents

module Kitabu
  class Syntax
    class Highlight
      def self.apply(code, language)
        if Dependency.pygments_rb?
          pygments(code, language)
        else
          coderay(code, language)
        end
      end

      private
      def self.pygments(code, language)
        Pygments.highlight(code, :lexer => language, :options => {:encoding => "utf-8"})
      end

      def self.coderay(code, language)
        CodeRay.scan(code, language).div(:css => :class)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kitabu-1.0.0.rc3 lib/kitabu/syntax/highlight.rb
kitabu-1.0.0.rc2 lib/kitabu/syntax/highlight.rb