markdown-maker 1.10.2 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/node.js.yml +21 -26
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +8 -3
- package/.vscode/snippets.code-snippets +6 -8
- package/jest.config.js +7 -0
- package/package.json +41 -40
- package/src/cltool.ts +113 -71
- package/src/commands.ts +237 -243
- package/src/errors.ts +26 -0
- package/src/main.ts +110 -109
- package/src/parser.ts +378 -350
- package/src/templates.ts +5 -1
- package/src/types.ts +33 -0
- package/tests/_test-util.ts +44 -0
- package/tests/advanced.spec.ts +92 -0
- package/tests/basic.spec.ts +68 -0
- package/tests/clargs.spec.ts +50 -0
- package/tests/errors.spec.ts +64 -0
- package/tests/html.spec.ts +23 -0
- package/tests/line.spec.ts +21 -0
- package/tests/marked.spec.ts +40 -0
- package/tests/target.spec.ts +41 -0
- package/tests/vars.spec.ts +45 -0
- package/tsconfig.json +66 -64
- package/prettierrc.yaml +0 -4
- package/test/advanced.test.js +0 -34
- package/test/basic.test.js +0 -67
- package/test/clargs.test.js +0 -51
- package/test/errors.test.js +0 -47
- package/test/hooks.js +0 -9
- package/test/hooks.test.js +0 -114
- package/test/html.test.js +0 -37
- package/test/line.test.js +0 -21
- package/test/marked.test.js +0 -43
- package/test/target.test.js +0 -43
- package/test/tester.test.js +0 -41
- package/test/vars.test.js +0 -49
package/test/tester.test.js
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const assert = require("assert");
|
3
|
-
const Parser = require("../bundle/parser");
|
4
|
-
const path = require("path");
|
5
|
-
const html = require("node-html-parser");
|
6
|
-
|
7
|
-
/* make folder for temporary files, if it doesn't exist */
|
8
|
-
if (
|
9
|
-
!fs.existsSync("test/test-files") ||
|
10
|
-
!fs.lstatSync("test/test-files").isDirectory()
|
11
|
-
) {
|
12
|
-
fs.mkdirSync("test/test-files");
|
13
|
-
}
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Create a new file under `test/test-files` with the given content.
|
17
|
-
* @param {string} text
|
18
|
-
* @param {string} file
|
19
|
-
*/
|
20
|
-
function put(text, file) {
|
21
|
-
fs.writeFileSync(path.join("test", "test-files", file), text);
|
22
|
-
}
|
23
|
-
function putDir(name) {
|
24
|
-
fs.mkdirSync(path.join("test", "test-files", name));
|
25
|
-
}
|
26
|
-
|
27
|
-
const TargetType = {
|
28
|
-
HTML: 0,
|
29
|
-
MARKDOWN: 1,
|
30
|
-
};
|
31
|
-
|
32
|
-
module.exports = {
|
33
|
-
assert,
|
34
|
-
fs,
|
35
|
-
html,
|
36
|
-
path,
|
37
|
-
Parser,
|
38
|
-
put,
|
39
|
-
putDir,
|
40
|
-
TargetType,
|
41
|
-
};
|
package/test/vars.test.js
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
const util = require("./tester.test.js");
|
2
|
-
|
3
|
-
describe("Use variables", () => {
|
4
|
-
it("should replace var with the value", () => {
|
5
|
-
const output = new util.Parser("#mddef<hi=yo>\n#mdvar<hi>").get();
|
6
|
-
|
7
|
-
util.assert.strictEqual(output, "\nyo\n\n");
|
8
|
-
});
|
9
|
-
it("should use variable shorthand", () => {
|
10
|
-
const output = new util.Parser("#mddef<hi=yo>\n<hi>").get();
|
11
|
-
|
12
|
-
util.assert.strictEqual(output, "\nyo\n\n");
|
13
|
-
});
|
14
|
-
it("should use variables across files", () => {
|
15
|
-
util.put("#mddef<hi=yo>\n#mdinclude<sample2.md>", "sample1.md");
|
16
|
-
util.put("<hi>", "sample2.md");
|
17
|
-
|
18
|
-
const output = new util.Parser("test/test-files/sample1.md").get();
|
19
|
-
|
20
|
-
util.assert.strictEqual(output, "\nyo\n\n");
|
21
|
-
});
|
22
|
-
it("should throw if undefined variable", () => {
|
23
|
-
const parser = new util.Parser("<yo>");
|
24
|
-
|
25
|
-
let e;
|
26
|
-
/* should throw an error */
|
27
|
-
util.assert.throws(() => {
|
28
|
-
try {
|
29
|
-
parser.get();
|
30
|
-
} catch (_e) {
|
31
|
-
e = _e;
|
32
|
-
throw _e;
|
33
|
-
}
|
34
|
-
});
|
35
|
-
});
|
36
|
-
|
37
|
-
it("should preserve whatever comes after", () => {
|
38
|
-
const output = new util.Parser("#mddef<hi=yo>\n<hi>,").get();
|
39
|
-
util.assert.strictEqual(output, "\nyo,\n\n");
|
40
|
-
});
|
41
|
-
|
42
|
-
it("should replace underscore with space", () => {
|
43
|
-
const output = new util.Parser(
|
44
|
-
"#mddef<name=Mr_Sir>\n#mdvar<name>"
|
45
|
-
).get();
|
46
|
-
|
47
|
-
util.assert.strictEqual(output, "\nMr Sir\n\n");
|
48
|
-
});
|
49
|
-
});
|