diff --git a/index.js b/index.js index 2126c8e..0146ad2 100755 --- a/index.js +++ b/index.js @@ -16,10 +16,12 @@ module.exports = function(file_path, callback){ } return result; } - var popTabStack = function(tabStack, current_line_num_tabs, previous_line_num_tabs){ + var popHTMLStack = function(html_stack, current_line_num_tabs, previous_line_num_tabs){ var result = ''; for(var i = previous_line_num_tabs; i > current_line_num_tabs; i--){ - result += tabStack.pop(); + result += html_stack.pop(); + result += html_stack.pop(); + result += html_stack.pop(); } return result; } @@ -31,7 +33,6 @@ module.exports = function(file_path, callback){ var html_stack = []; for(var i = 0; i < lines.length; i++){ if(lines[i] !== ''){ - console.log(i + lines[i]); var tabs_array = lines[i].split('\t'); var current_line_num_tabs = tabs_array.length - 1; if(current_line_num_tabs > previous_line_num_tabs){ @@ -40,6 +41,9 @@ module.exports = function(file_path, callback){ } else if (current_line_num_tabs === previous_line_num_tabs) { html += html_stack.pop(); } + else if(current_line_num_tabs < previous_line_num_tabs){ + html += popHTMLStack(html_stack, current_line_num_tabs, previous_line_num_tabs); + } html += insertTabs((current_line_num_tabs * 2) + 1) + '