Skip to content
Browse files

clean text better. dont indent empty lines.

  • Loading branch information...
1 parent 3452805 commit cf4f9665c23b2719face5c9fcdece3af9ff5669b @chjj committed Mar 9, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/lexer.js
View
9 lib/lexer.js
@@ -4,8 +4,11 @@
*/
var lexer = function(src, options) {
- var src = src.replace(/\r\n|\r/g, '\n')
- , i = 0
+ src = src
+ .replace(/\r\n|\r/g, '\n')
+ .replace(/\s+$/gm, '');
+
+ var i = 0
, l = src.length
, ch
, buff = ''
@@ -216,7 +219,7 @@ var indentation = function(src, n) {
if (!n) return src;
var s = '';
while (n--) s += ' ';
- return src.replace(/^/gm, s);
+ return src.replace(/^(?!\s*$)/gm, s);
};
/**

0 comments on commit cf4f966

Please sign in to comment.
Something went wrong with that request. Please try again.