can tell when new indentation happens

master
Matt Huntington 10 years ago
parent c7b98d37cd
commit 2299d9a40e

@ -1,13 +1,31 @@
#!/usr/bin/env node #!/usr/bin/env node
fs = require('fs'); fs = require('fs');
var parseFile = function(data){
console.log(data); var parseFile = function(data, callback){
var previous_line = -1;
var lines = data.split('\n');
var html = '';
lines.forEach(function(value, index){
if(value !== ''){
var split_value = value.split('\t');
var num_tabs = split_value.length - 1;
if(num_tabs > previous_line){
html += "<ul>";
}
html += '<li>' + split_value[split_value.length-1] + '</li>';
previous_line = num_tabs;
}
});
callback(html);
} }
fs.readFile(process.argv[2], 'utf8', function(err, data){ fs.readFile(process.argv[2], 'utf8', function(err, data){
if(err){ if(err){
console.log(err); console.log(err);
} else { } else {
parseFile(data); parseFile(data, function(html){
console.log(html);
});
} }
}); });

Loading…
Cancel
Save