Sha256: a1f4280e210280531c023d80fcf2975e8f21fdd03c07d61b734b04e86817e0ed

Contents?: true

Size: 824 Bytes

Versions: 23

Compression:

Stored size: 824 Bytes

Contents

# -*- coding: utf-8 -*- #
# frozen_string_literal: true

module Rouge
  module Lexers
    class Email < RegexLexer
      tag 'email'
      aliases 'eml', 'e-mail'
      filenames '*.eml'
      mimetypes 'message/rfc822'

      title "Email"
      desc "An email message"

      start do
        push :fields
      end

      state :fields do
        rule %r/[:]/, Operator, :field_body
        rule %r/[^\n\r:]+/, Name::Tag
        rule %r/[\n\r]/, Name::Tag
      end

      state :field_body do
        rule(/(\r?\n){2}/) { token Text; pop!(2) }
        rule %r/\r?\n(?![ \v\t\f])/, Text, :pop!
        rule %r/[^\n\r]+/, Name::Attribute
        rule %r/[\n\r]/, Name::Attribute
      end

      state :root do
        rule %r/\n/, Text
        rule %r/^>.*/, Comment
        rule %r/.+/, Text
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
rouge-3.26.0 lib/rouge/lexers/email.rb
rouge-3.25.0 lib/rouge/lexers/email.rb
rouge-3.24.0 lib/rouge/lexers/email.rb