-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (29 loc) · 713 Bytes
/
index.js
File metadata and controls
32 lines (29 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const h2m = 1;
const m2h = 2;
import { Converter } from 'showdown';
const converter = new Converter();
import { red } from 'chalk';
const error = red.bold;
import { readFileSync, writeFileSync } from 'fs';
function typerror(){
console.log(error("The `typ` selection should be input as `hm` or `mh`"));
console.log(error("See"));
}
function make(typ, bef, aft) {
let con;
let text = readFileSync(bef).toString();
if (typ == 1) {
con = converter.makeMd(text);
} else if (typ == 2) {
con = converter.makeHtml(text);
} else {
typerror();
}
let output = writeFileSync(aft, con);
console.log(output);
}
export default {
h2m,
m2h,
make
};