Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

use different method of determining indentSize

  • Loading branch information...
commit de6c8bf1033d9c9bd4ea7c211e78c84b9b4642a2 1 parent e565177
Christopher Jeffrey authored March 06, 2012

Showing 1 changed file with 5 additions and 13 deletions. Show diff stats Hide diff stats

  1. 18  lib/lexer.js
18  lib/lexer.js
@@ -20,10 +20,10 @@ var lexer = function(str, options) {
20 20
     , indent
21 21
     , indents = []
22 22
     , newline = true
23  
-    , indentSize = getIndentSize(str);
  23
+    , indentSize;
24 24
 
25 25
   if (options.pretty && options.indent) {
26  
-    str = applyIndent(str, options.indent * indentSize);
  26
+    str = applyIndent(str, options.indent);
27 27
     l = str.length;
28 28
   }
29 29
 
@@ -43,10 +43,9 @@ var lexer = function(str, options) {
43 43
     offset++;
44 44
 
45 45
     if (ch > ' ' && newline) {
46  
-      // wont work with indent option:
47  
-      // if (!indentSize && indent != null && indent < buff.length) {
48  
-      //   indentSize = buff.length - indent;
49  
-      // }
  46
+      if (!indentSize && indent != null && indent < buff.length) {
  47
+        indentSize = buff.length - indent;
  48
+      }
50 49
       indent = buff.length;
51 50
       // assert(indent % indentSize === 0);
52 51
       while (indents[indents.length-1] >= indent) {
@@ -203,13 +202,6 @@ var applyIndent = function(str, n) {
203 202
   return str.replace(/^/gm, s);
204 203
 };
205 204
 
206  
-var getIndentSize = function(str) {
207  
-  var start = /^([ \t]+)(?:[^\n]+\n\1)+/.exec(str);
208  
-  if (start) str = applyOutdent(str, start[1].length);
209  
-  var size = /\n([ \t]+)/.exec(str);
210  
-  return size ? size[1].length : 0;
211  
-};
212  
-
213 205
 /**
214 206
  * Expose
215 207
  */

0 notes on commit de6c8bf

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