moving processing of single line into separate function

master
Matt Huntington 10 years ago
parent 3925b51093
commit 4270a91c3c

@ -40,20 +40,24 @@ module.exports = function(input){
previous_line_num_tabs = current_line_num_tabs; previous_line_num_tabs = current_line_num_tabs;
} }
var processSingleLine = function(i){
html += popHTMLStack(-1, previous_line_num_tabs);
previous_line_num_tabs = -1;
if(lines[i].indexOf('.') > 0){
html += '<p>' + lines[i] + '</p>\n';
} else if( i > 0 ) {
html += '<h2>' + lines[i] + '</h2>\n';
} else {
html += '<h1>' + lines[i] + '</h1>\n';
}
}
var parseFile = function(data){ var parseFile = function(data){
lines = data.split('\n'); lines = data.split('\n');
for(var i = 0; i < lines.length; i++){ for(var i = 0; i < lines.length; i++){
if(lines[i] !== ''){ if(lines[i] !== ''){
if(lines[ i + 1 ] === '' && (i === 0 || lines[ i - 1 ] === '')){ if(lines[ i + 1 ] === '' && (i === 0 || lines[ i - 1 ] === '')){
html += popHTMLStack(-1, previous_line_num_tabs); processSingleLine(i);
previous_line_num_tabs = -1;
if(lines[i].indexOf('.') > 0){
html += '<p>' + lines[i] + '</p>\n';
} else if( i > 0 ) {
html += '<h2>' + lines[i] + '</h2>\n';
} else {
html += '<h1>' + lines[i] + '</h1>\n';
}
} else { } else {
processList(i); processList(i);
} }

Loading…
Cancel
Save