Sha256: 70c4558645ddd635e054292d7d7ea15b4432b393353ca0a0534d6a10cf0a8790

Contents?: true

Size: 786 Bytes

Versions: 14

Compression:

Stored size: 786 Bytes

Contents

module Rouge
  module Lexers
    class LiterateHaskell < RegexLexer
      desc 'Literate haskell'
      tag 'literate_haskell'
      aliases 'lithaskell', 'lhaskell', 'lhs'
      filenames '*.lhs'
      mimetypes 'text/x-literate-haskell'

      def haskell
        @haskell ||= Haskell.new(options)
      end

      start { haskell.reset! }

      # TODO: support TeX versions as well.
      # TODO: enforce a blank line before and after code
      state :root do
        rule /\s*?\n(?=>)/, 'Text', :code
        rule /.*?\n/, 'Text'
        rule /.+\z/, 'Text'
      end

      state :code do
        rule /(>)( .*?\n)/ do |m|
          token 'Name.Label', m[1]
          delegate haskell, m[2]
        end

        rule /\s*\n(?=\s*[^>])/, 'Text', :pop!
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rouge-0.4.0 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.10 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.9 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.8 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.7 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.6 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.5 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.4 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.3 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.2 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.1 lib/rouge/lexers/literate_haskell.rb
rouge-0.3.0 lib/rouge/lexers/literate_haskell.rb
rouge-0.2.15 lib/rouge/lexers/literate_haskell.rb
rouge-0.2.14 lib/rouge/lexers/literate_haskell.rb