Mon, 06 Jul 2020 12:51:11 -0500
Attempt markdown-it-texmath instead of markdown-it-katex.
#!/usr/bin/env node /*eslint no-console:0*/ var fs = require('fs'); var hljs = require('highlight.js'); // process.argv[0] seems to be the node executable itself if(process.argv.length<=2){ console.error(`Usage: ${process.argv[1]} input_file`) process.exit(1); } fs.readFile(process.argv[2], 'utf8', function (err, input) { var output, md; if(err){ console.error(err.stack || err.message || String(err)); process.exit(1); } try{ var md = require('markdown-it')({ html: true, xhtmlOut: true, breaks: false, linkify: true, highlight: function (str, lang) { if (lang && hljs.getLanguage(lang)) { try{ return hljs.highlight(lang, str).value; } catch (__){} } return ''; } }), mk = require('markdown-it-texmath', { engine: require('katex'), delimiters:'dollars' }), mm = require('markdown-it-mark'); md.use(mk).use(mm); output = md.render(input); } catch(e) { console.error(e.stack || e.message || String(e)); process.exit(1); } process.stdout.write(output); });