From 978a6c5a43e910f322a476fb69230e6ec95e8a82 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 14 Jun 2014 00:59:19 -0300 Subject: [PATCH] See #14. Add JSON support. JSON is processed as if it were JavaScript. I have tested it (see examples/simple-jsbeautifyrc/test.json) and it works as expected and supports comments! --- examples/simple-jsbeautifyrc/test.json | 9 +++++++++ lib/atom-beautify.js | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 examples/simple-jsbeautifyrc/test.json diff --git a/examples/simple-jsbeautifyrc/test.json b/examples/simple-jsbeautifyrc/test.json new file mode 100644 index 0000000..75f283d --- /dev/null +++ b/examples/simple-jsbeautifyrc/test.json @@ -0,0 +1,9 @@ +{ + "indent_size": 2, +"indent_char": " ", // test + "indent_level": 0, +"indent_with_tabs": false, /* test */ + "preserve_newlines": true, +"max_preserve_newlines": 2, /* test * + "jslint_happy": true +} diff --git a/lib/atom-beautify.js b/lib/atom-beautify.js index 7c9509b..14e145b 100644 --- a/lib/atom-beautify.js +++ b/lib/atom-beautify.js @@ -244,6 +244,9 @@ function beautify() { } switch (editor.getGrammar().name) { + case 'JSON': + // Treat JSON as JavaScript, because it will support comments. + // And Glavin001 has tested JSON beauifying with beautifyJS. case 'JavaScript': text = beautifyJS(text, getOptions('js', allOptions)); break;