From 1f0fb9c0db43b71816caf3c1d1d235484cbcd53a Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sun, 3 Aug 2014 23:35:48 -0400 Subject: [PATCH] Closes #44. Switch to using Pretty Diff for SASS, as well. See #54. Use indent_size and indent_character options. --- examples/simple-jsbeautifyrc/test.sass | 6 ++++++ lib/langs/less-beautify.js | 4 +++- lib/language-options.js | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 examples/simple-jsbeautifyrc/test.sass diff --git a/examples/simple-jsbeautifyrc/test.sass b/examples/simple-jsbeautifyrc/test.sass new file mode 100644 index 0000000..44e52bb --- /dev/null +++ b/examples/simple-jsbeautifyrc/test.sass @@ -0,0 +1,6 @@ +a { +line-height: 56px; +&:hover { + color: blue; +} +} diff --git a/lib/langs/less-beautify.js b/lib/langs/less-beautify.js index f4f9bce..d4ca05d 100644 --- a/lib/langs/less-beautify.js +++ b/lib/langs/less-beautify.js @@ -6,7 +6,9 @@ module.exports = function (text, options, callback) { var args = { source: text, lang: 'css', - mode: 'beautify' + mode: 'beautify', + inchar: options.indent_character, + insize: options.indent_size }, output = prettydiff.api(args); var result = output[0]; diff --git a/lib/language-options.js b/lib/language-options.js index c6c2ee2..0d2e51d 100644 --- a/lib/language-options.js +++ b/lib/language-options.js @@ -15,6 +15,7 @@ var beautifyPHP = require('./langs/php-beautify'); var beautifyPython = require('./langs/python-beautify'); var beautifyRuby = require('./langs/ruby-beautify'); var beautifyLESS = require('./langs/less-beautify'); +var beautifySASS = beautifyLESS; var beautifyCoffeeScript = require('./langs/coffeescript-beautify'); // Misc var Analytics = require('analytics-node'); @@ -98,12 +99,12 @@ module.exports = { text = beautifyHTML(text, self.getOptions('html', allOptions)); beautifyCompleted(text); break; - case 'Sass': - case 'SCSS': case 'CSS': text = beautifyCSS(text, self.getOptions('css', allOptions)); beautifyCompleted(text); break; + case 'Sass': + case 'SCSS': case 'LESS': beautifyLESS(text, self.getOptions('css', allOptions), beautifyCompleted); break;