From 48a5aa500a9997e5b8fb65cc842787f26e5a1215 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sun, 12 Apr 2020 12:09:24 +0900 Subject: [PATCH 1/3] Add test of missing opening brace to visual sample --- spec/visual/samples/json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/visual/samples/json b/spec/visual/samples/json index c8b7a17c51..da7a21860d 100644 --- a/spec/visual/samples/json +++ b/spec/visual/samples/json @@ -142,3 +142,7 @@ null \"ci_builds\".\"name\", \"ci_builds\".\"commit_id\")" } {"message":"\\\"retry_count\\\":0}\"}"} + + "This is a test": "of missing opening brace" +} + From 4a115ee7977ac172c941e9ce3f9767cdf725bf16 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sun, 12 Apr 2020 12:09:50 +0900 Subject: [PATCH 2/3] Add simple rule to match closing braces and brackets --- lib/rouge/lexers/json.rb | 3 +++ 1 file changed, 3 insertions(+) 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 From 27350f6c6279ef57b8f19cf8984501181c156f42 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Tue, 14 Apr 2020 09:22:58 +0900 Subject: [PATCH 3/3] Add additional examples to visual sample --- spec/visual/samples/json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/visual/samples/json b/spec/visual/samples/json index da7a21860d..0452bcc966 100644 --- a/spec/visual/samples/json +++ b/spec/visual/samples/json @@ -143,6 +143,11 @@ null {"message":"\\\"retry_count\\\":0}\"}"} - "This is a test": "of missing opening brace" + "This is a test": "of missing an opening brace" } + "This is a test": "of missing an opening bracket" +] + +{"This is a correct": "JSON object"} +