UNPKG

markugen

Version:

Markdown to HTML/PDF static site generation tool

54 lines (53 loc) 1.71 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.HtmlToPdf = void 0; const markugen_1 = __importDefault(require("../markugen")); const markugenargs_1 = require("./markugenargs"); class HtmlToPdf { command = ['pdf', 'htmltopdf']; describe = 'HTML to PDF file generation'; builder(args) { args.options({ input: { alias: ['i'], describe: 'the directory to locate the markdown files, a single file, ' + 'or a string of markdown', type: 'string', demandOption: true, }, extensions: { alias: ['exts'], describe: 'list of file extensions to search the input directory for', type: 'array', default: ['html'], }, links: { alias: ['l'], describe: 'if true, markdown links generated by Markugen will be converted ' + 'to PDF links', type: 'boolean', default: true }, ...markugenargs_1.MarkugenArgs, }); return args; } ; async handler(args) { // create the markugen instance let mark = undefined; try { mark = new markugen_1.default({ cli: true }); await mark.htmltopdf({ ...args, cli: true }); } catch (e) { mark?.error(e); process.exit(1); } } ; } exports.HtmlToPdf = HtmlToPdf;