Sha256: fdde3c6cb18fbe8b4921cad95b6cf187fac71a2acbf6eb2f98e89c0ec2ccb4cb

Contents?: true

Size: 764 Bytes

Versions: 4

Compression:

Stored size: 764 Bytes

Contents

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

module Rouge
  module Lexers
    class JSON < RegexLexer
      desc "JavaScript Object Notation (json.org)"
      tag 'json'
      filenames '*.json'
      mimetypes 'application/json', 'application/vnd.api+json',
                'application/hal+json'

      state :root do
        rule /\s+/m, Text::Whitespace
        rule /"/, Str::Double, :string
        rule /(?:true|false|null)\b/, Keyword::Constant
        rule /[{},:\[\]]/, Punctuation
        rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
        rule /-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
      end

      state :string do
        rule /[^\\"]+/, Str::Double
        rule /\\./, Str::Escape
        rule /"/, Str::Double, :pop!
      end
    end
  end
end

Version data entries

4 entries across 3 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/json.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/json.rb
tdiary-5.0.4 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/json.rb
rouge-2.0.7 lib/rouge/lexers/json.rb