Sha256: 490163693842b2d558f21b27c951b93b898e12d5a0674e5fc43cb8ce49ed0b21

Contents?: true

Size: 464 Bytes

Versions: 2

Compression:

Stored size: 464 Bytes

Contents

module TermNote
  module Pane
    class Code
      include Pane

      attr_accessor :source, :language

      def initialize(options)
        @source = options[:source] || options['source']
        @language = options[:language] || options['language']
      end

      def rows
        highlighted.split("\n")
      end

      private

      def highlighted
        Pygments.highlight source, formatter: 'terminal256', lexer: language
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
termnote-1.1.0 lib/termnote/pane/code.rb
termnote-1.0.0 lib/termnote/pane/code.rb