2020-12-22 11:14:44 -06:00
|
|
|
const showdown = require("showdown");
|
|
|
|
const converter = new showdown.Converter();
|
2020-12-22 09:15:14 -06:00
|
|
|
const nunjucks = require("nunjucks");
|
2020-12-22 11:14:44 -06:00
|
|
|
const fs = require("fs");
|
2020-12-22 09:15:14 -06:00
|
|
|
|
|
|
|
async function main (){
|
|
|
|
nunjucks.configure({
|
|
|
|
autoescape: true
|
|
|
|
});
|
2020-12-22 11:14:44 -06:00
|
|
|
try{ fs.mkdirSync('dist'); }
|
|
|
|
catch {}
|
|
|
|
var articles = fs.readdirSync('articles');
|
|
|
|
for(var i=0;i<articles.length;i++){
|
|
|
|
var article = fs.readFileSync('articles/'+articles[i], {encoding: 'utf-8'});
|
|
|
|
article = converter.makeHtml(article);
|
|
|
|
fs.writeFileSync('dist/'+articles[i].substring(0, articles[i].length - 3)+'.html', article, {encoding: 'utf-8'});
|
|
|
|
}
|
|
|
|
//var test = fs.readFileSync("./test.md", {encoding: 'utf-8'});
|
2020-12-22 09:15:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.main = main;
|