dealing with headings

master
Matt Huntington 10 years ago
parent 752ebb1ef5
commit c46b60dd26

@ -28,6 +28,15 @@ module.exports = function(input){
var html = '';
for(var i = 0; i < lines.length; i++){
if(lines[i] !== ''){
if(lines[ i + 1 ] === '' && (i === 0 || lines[ i - 1 ] === '')){
html += popHTMLStack(-1, previous_line_num_tabs);
previous_line_num_tabs = -1;
if( i > 0 ) {
html += '<h2>' + lines[i] + '</h2>\n';
} else {
html += '<h1>' + lines[i] + '</h1>\n';
}
} else {
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){
@ -42,7 +51,9 @@ module.exports = function(input){
previous_line_num_tabs = current_line_num_tabs;
}
}
}
html += popHTMLStack(-1, previous_line_num_tabs);
previous_line_num_tabs = -1;
return html
}

Loading…
Cancel
Save