| 1 #!/usr/bin/env node |
1 #!/usr/bin/env node |
| 2 /*eslint no-console:0*/ |
2 /*eslint no-console:0*/ |
| 3 |
3 |
| 4 var fs = require('fs'); |
4 var fs = require('fs'); |
| 5 var hljs = require('highlight.js'); |
5 var hljs = require('highlight.js'); |
| |
6 |
| |
7 var katexOptions = { |
| |
8 throwOnError: false, |
| |
9 macros: { |
| |
10 "\\iprod": "{\\langle #1, #2\\rangle}", |
| |
11 "\\grad": "\\nabla", |
| |
12 "\\isect": "\\cap", |
| |
13 "\\union": "\\cup", |
| |
14 "\\Isect": "\\bigcap", |
| |
15 "\\Union": "\\bigcup", |
| |
16 "\\supp": "\\mathop{\\mathrm{supp}}", |
| |
17 "\\sign": "\\mathop{\\mathrm{sign}}", |
| |
18 "\\Id": "\\mathop{\\mathrm{Id}}", |
| |
19 "\\linear": "\\mathbb{L}" |
| |
20 } |
| |
21 }; |
| 6 |
22 |
| 7 // process.argv[0] seems to be the node executable itself |
23 // process.argv[0] seems to be the node executable itself |
| 8 if(process.argv.length<=2){ |
24 if(process.argv.length<=2){ |
| 9 console.error(`Usage: ${process.argv[1]} input_file`) |
25 console.error(`Usage: ${process.argv[1]} input_file`) |
| 10 process.exit(1); |
26 process.exit(1); |
| 30 return hljs.highlight(lang, str).value; |
46 return hljs.highlight(lang, str).value; |
| 31 } catch (__){} |
47 } catch (__){} |
| 32 } |
48 } |
| 33 return ''; |
49 return ''; |
| 34 } |
50 } |
| 35 }), |
51 }) |
| 36 mk = require('markdown-it-katex'), |
52 var mk = require('@neilsustc/markdown-it-katex'); |
| 37 mm = require('markdown-it-mark'); |
53 var mm = require('markdown-it-mark'); |
| 38 md.use(mk).use(mm); |
54 md.use(mk, katexOptions).use(mm); |
| 39 output = md.render(input); |
55 output = md.render(input); |
| 40 } catch(e) { |
56 } catch(e) { |
| 41 console.error(e.stack || e.message || String(e)); |
57 console.error(e.stack || e.message || String(e)); |
| 42 process.exit(1); |
58 process.exit(1); |
| 43 } |
59 } |