From 2b2f5944509c55aaebf5a6da37d181f0ebcefcd8 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 21 Nov 2013 03:21:23 +0100 Subject: [PATCH 1/2] Option for indentation string --- bin/cssbeautify | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/cssbeautify b/bin/cssbeautify index 40afd7f..4ea2ebf 100755 --- a/bin/cssbeautify +++ b/bin/cssbeautify @@ -36,6 +36,7 @@ function showUsage() { console.log(); console.log('Available options:'); console.log(); + console.log(' --indent= Indent content with string '); console.log(' -v, --version Shows program version'); console.log(); process.exit(1); @@ -56,6 +57,8 @@ process.argv.splice(2).forEach(function (entry) { console.log('CSS Beautify version 0.3.0'); console.log(); process.exit(0); + } else if (entry.slice(0,9) === '--indent=') { + options.indent = entry.slice(9); } else if (entry.slice(0, 2) === '--') { console.log('Error: unknown option ' + entry + '.'); process.exit(1); @@ -74,7 +77,7 @@ if (typeof fname !== 'string') { try { content = fs.readFileSync(fname, 'utf-8'); - style = cssbeautify(content); + style = cssbeautify(content, options); console.log(style); } catch (e) { console.log('Error: ' + e.message); From 5ca95fc2a3aa3caf10f9d573aafa9a469e990289 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 21 Nov 2013 15:24:34 +0100 Subject: [PATCH 2/2] Don't keep adding trailing white space. --- cssbeautify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cssbeautify.js b/cssbeautify.js index b4ae096..287f82e 100644 --- a/cssbeautify.js +++ b/cssbeautify.js @@ -453,7 +453,7 @@ formatted += ch; } - formatted = blocks.join('') + formatted; + formatted = blocks.join('') + trimRight(formatted); return formatted; }