@f-fjs/tidy-markdown
Version:
Fix ugly markdown.
37 lines • 1.4 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const argparse_1 = require("argparse");
const _1 = __importDefault(require("./"));
// tslint:disable-next-line: no-var-requires
const packageInfo = require('../package.json');
const argparser = new argparse_1.ArgumentParser({
addHelp: true,
description: packageInfo.description + ` Unformatted Markdown is read from \
STDIN, formatted, and written to STDOUT.`,
version: packageInfo.version
});
argparser.addArgument(['--no-ensure-first-header-is-h1'], {
action: 'storeFalse',
help: `Disable fixing the first header when it isn\'t an H1. This is useful if \
the markdown you\'re processing isn\'t a full document, but rather a piece of \
a larger document.`,
defaultValue: true,
dest: 'ensureFirstHeaderIsH1'
});
const argv = argparser.parseArgs();
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
let chunk;
let buffer = '';
// tslint:disable-next-line: no-conditional-assignment
while ((chunk = process.stdin.read()) !== null) {
buffer += chunk;
}
if (buffer !== '') {
process.stdout.write(_1.default(buffer, argv));
}
});
//# sourceMappingURL=cli.js.map