Sha256: d5ccb149800a67f6a62e9e04a159d6a0994888713990894096769d06756657fb

Contents?: true

Size: 1.06 KB

Versions: 42

Compression:

Stored size: 1.06 KB

Contents

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

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 %r/[;#].*?\n/, Comment
        rule %r/\s+/, Text
        rule %r/\\\n/, Str::Escape
      end

      state :root do
        mixin :basic

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

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

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

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

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

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
rouge-4.4.0 lib/rouge/lexers/ini.rb
rouge-4.3.0 lib/rouge/lexers/ini.rb
rouge-4.2.1 lib/rouge/lexers/ini.rb
rouge-4.2.0 lib/rouge/lexers/ini.rb
rouge-4.1.3 lib/rouge/lexers/ini.rb
rouge-4.1.2 lib/rouge/lexers/ini.rb
rouge-4.1.1 lib/rouge/lexers/ini.rb
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/lexers/ini.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/rouge-3.30.0/lib/rouge/lexers/ini.rb
rouge-4.1.0 lib/rouge/lexers/ini.rb
rouge-4.0.1 lib/rouge/lexers/ini.rb
rouge-4.0.0 lib/rouge/lexers/ini.rb
rouge-3.30.0 lib/rouge/lexers/ini.rb
rouge-3.29.0 lib/rouge/lexers/ini.rb
rouge-3.28.0 lib/rouge/lexers/ini.rb
rouge-3.27.0 lib/rouge/lexers/ini.rb
rouge-3.26.1 lib/rouge/lexers/ini.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/rouge-3.26.0/lib/rouge/lexers/ini.rb
rouge-3.26.0 lib/rouge/lexers/ini.rb
rouge-3.25.0 lib/rouge/lexers/ini.rb