mirror of
https://github.com/r-ca/md2pdf-meow.git
synced 2024-11-26 17:23:14 +00:00
37 lines
914 B
JavaScript
Executable File
37 lines
914 B
JavaScript
Executable File
/*
|
|
* md2html
|
|
* Copyright 2019 2SC1815J, MIT license
|
|
*/
|
|
'use strict';
|
|
if (process.argv.length < 4) {
|
|
console.error('Usage: node ejs.js template.html output.html');
|
|
process.exit(1);
|
|
}
|
|
|
|
const { promisify } = require('util');
|
|
const ejs = require('ejs');
|
|
const tidy = require('htmltidy2');
|
|
const fs = require('fs');
|
|
|
|
(async () => {
|
|
const text = await promisify(ejs.renderFile)(process.argv[2]);
|
|
const options = {
|
|
doctype: 'html5',
|
|
indent: 'auto',
|
|
wrap: 0,
|
|
tidyMark: false,
|
|
quoteAmpersand: false,
|
|
hideComments: true,
|
|
dropEmptyElements: false,
|
|
newline: 'LF'
|
|
};
|
|
const tidied = await promisify(tidy.tidy)(text, options);
|
|
await promisify(fs.writeFile)(process.argv[3], tidied, 'utf8');
|
|
})()
|
|
.then(() => {
|
|
console.log('Done.');
|
|
})
|
|
.catch((err) => {
|
|
console.error(err);
|
|
process.exit(1);
|
|
}); |