nicojensen.de/vendor/bundle/gems/rouge-3.3.0/lib/rouge/lexers/json.rb
Nico Jensen b59a203dbb Init
Init commit
2019-03-12 13:49:49 +01:00

30 lines
815 B
Ruby

# -*- 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'
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