const showdown = require('showdown'); const showdownKatex = require('showdown-katex'); const fs = require('fs/promises'); const path = require('path'); const converter = new showdown.Converter({ extensions: [showdownKatex()], }); if (process.argv.length < 3) { process.exit(1); } async function readFile(filename) { try { const data = await fs.readFile(filename, { encoding: 'utf-8' }); return data; } catch (err) { console.error(err); } console.log('fuck'); } async function makeHtml() { const markdown = await readFile(process.argv[2]); const newFileName = path.parse(process.argv[2]).name + '.html'; const html = converter.makeHtml(markdown); let contents = ` Benjamin Bergstrom's blog

~ back to blog

${html}
`; try { await fs.writeFile(`articles/${newFileName}`, contents); console.log( `Open at https://tilde.team/~benko11/blog/articles/${newFileName}` ); } catch (err) { console.error(err); return; } } makeHtml();