You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cml-html-converter/index.js

32 lines
645 B

#!/usr/bin/env node
fs = require('fs');
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){
if(err){
console.log(err);
} else {
parseFile(data, function(html){
console.log(html);
});
}
});