Sha256: 13d90aa4a15f8992cf8b4dc73e12fcf69b51fed6664daaac78c2259160557d42

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rouge-3.6.0 lib/rouge/lexers/json.rb