-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
43 lines (33 loc) · 845 Bytes
/
test.js
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
33
34
35
36
37
38
39
40
41
42
43
const fs = require("fs");
const path = require("path");
const { marked } = require("marked");
const RenderToText = require("marked-renderer-text");
const testFile = fs.readFileSync(path.join(__dirname, "testText.md"), "utf-8");
// With marked.use
marked.use({
renderer: new RenderToText(false),
});
fs.writeFileSync(
path.join(__dirname, "boring.output.txt"),
marked.parse(testFile)
);
marked.use({
renderer: new RenderToText(true),
});
fs.writeFileSync(
path.join(__dirname, "fancy.output.txt"),
marked.parse(testFile)
);
// By passing options to the parse function
fs.writeFileSync(
path.join(__dirname, "boring.output.txt"),
marked.parse(testFile, {
renderer: new RenderToText(false),
})
);
fs.writeFileSync(
path.join(__dirname, "fancy.output.txt"),
marked.parse(testFile, {
renderer: new RenderToText(true),
})
);