Sha256: 7047f286cb7c5ee3460b5abbc968f493b5d4f4cbfa023fae0168c2f9aafe2c81
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Lexers class TOML < RegexLexer title "TOML" desc 'the TOML configuration format (https://github.com/mojombo/toml)' tag 'toml' filenames '*.toml', 'Pipfile' mimetypes 'text/x-toml' identifier = /\S+/ state :basic do rule %r/\s+/, Text rule %r/#.*?$/, Comment rule %r/(true|false)/, Keyword::Constant rule %r/(\S+)(\s*)(=)(\s*)(\{)/ do |m| groups Name::Namespace, Text, Operator, Text, Punctuation push :inline end rule %r/(?<!=)\s*\[[\S]+\]/, Name::Namespace rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date rule %r/(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, Num::Float rule %r/\d+[eE][+-]?[0-9]+j?/, Num::Float rule %r/\-?\d+/, Num::Integer end state :root do mixin :basic rule %r/(#{identifier})(\s*)(=)/ do groups Name::Property, Text, Punctuation push :value end end state :value do rule %r/\n/, Text, :pop! mixin :content end state :content do mixin :basic rule %r/"/, Str, :dq mixin :esc_str rule %r/\,/, Punctuation rule %r/\[/, Punctuation, :array end state :dq do rule %r/"/, Str, :pop! mixin :esc_str rule %r/[^\\"]+/, Str end state :esc_str do rule %r/\\[0t\tn\n "\\r]/, Str::Escape end state :array do mixin :content rule %r/\]/, Punctuation, :pop! end state :inline do mixin :content rule %r/(#{identifier})(\s*)(=)/ do groups Name::Property, Text, Punctuation end rule %r/\}/, Punctuation, :pop! end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rouge-3.15.0 | lib/rouge/lexers/toml.rb |
rouge-3.14.0 | lib/rouge/lexers/toml.rb |