diff --git a/lib/rouge/lexers/json.rb b/lib/rouge/lexers/json.rb index f8fd53dc58..85228bf43e 100644 --- a/lib/rouge/lexers/json.rb +++ b/lib/rouge/lexers/json.rb @@ -23,6 +23,9 @@ class JSON < RegexLexer mixin :name mixin :value + + # These characters may be invalid but syntax correctness is a non-goal + rule %r/[\]}]/, Punctuation end state :object do diff --git a/spec/visual/samples/json b/spec/visual/samples/json index c8b7a17c51..0452bcc966 100644 --- a/spec/visual/samples/json +++ b/spec/visual/samples/json @@ -142,3 +142,12 @@ null \"ci_builds\".\"name\", \"ci_builds\".\"commit_id\")" } {"message":"\\\"retry_count\\\":0}\"}"} + + "This is a test": "of missing an opening brace" +} + + "This is a test": "of missing an opening bracket" +] + +{"This is a correct": "JSON object"} +