Sha256: c36a5af3523431e15d9309c8415359f2ff6a5e48fad208c749441b38ad987c70

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

# -*- coding: utf-8 -*- #

module Rouge
  module Lexers
    class INI < RegexLexer
      title "INI"
      desc 'the INI configuration format'
      tag 'ini'

      # TODO add more here
      filenames '*.ini', '*.INI', '*.gitconfig'
      mimetypes 'text/x-ini'

      identifier = /[\w\-.]+/

      state :basic do
        rule /[;#].*?\n/, Comment
        rule /\s+/, Text
        rule /\\\n/, Str::Escape
      end

      state :root do
        mixin :basic

        rule /(#{identifier})(\s*)(=)/ do
          groups Name::Property, Text, Punctuation
          push :value
        end

        rule /\[.*?\]/, Name::Namespace
      end

      state :value do
        rule /\n/, Text, :pop!
        mixin :basic
        rule /"/, Str, :dq
        rule /'.*?'/, Str
        mixin :esc_str
        rule /[^\\\n]+/, Str
      end

      state :dq do
        rule /"/, Str, :pop!
        mixin :esc_str
        rule /[^\\"]+/m, Str
      end

      state :esc_str do
        rule /\\./m, Str::Escape
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rouge-3.2.1 lib/rouge/lexers/ini.rb
rouge-3.2.0 lib/rouge/lexers/ini.rb
rouge_ecl-0.0.1 lib/rouge/lexers/ini.rb
rouge-3.1.1 lib/rouge/lexers/ini.rb
rouge-3.1.0 lib/rouge/lexers/ini.rb
rouge-3.0.0 lib/rouge/lexers/ini.rb