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
@@ -1,35 +1,30 @@
|
|
1
1
|
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
2
2
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
3
3
|
|
4
|
-
name:
|
4
|
+
name: Jest
|
5
5
|
|
6
6
|
on: [push, pull_request]
|
7
7
|
|
8
8
|
jobs:
|
9
|
-
|
9
|
+
build:
|
10
|
+
runs-on: ubuntu-latest
|
10
11
|
|
11
|
-
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
node-version: [20.x, 21.x, 22.x]
|
15
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
cmd: install # will run `yarn install` command
|
28
|
-
- name: yarn build
|
29
|
-
uses: borales/actions-yarn@v3.0.0
|
30
|
-
with:
|
31
|
-
cmd: build # will run `yarn build` command
|
32
|
-
- name: yarn test
|
33
|
-
uses: borales/actions-yarn@v3.0.0
|
34
|
-
with:
|
35
|
-
cmd: test # will run `yarn test` command
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
20
|
+
uses: actions/setup-node@v1
|
21
|
+
with:
|
22
|
+
node-version: ${{ matrix.node-version }}
|
23
|
+
- name: yarn install
|
24
|
+
uses: borales/actions-yarn@v3.0.0
|
25
|
+
with:
|
26
|
+
cmd: install # will run `yarn install` command
|
27
|
+
- name: yarn test
|
28
|
+
uses: borales/actions-yarn@v3.0.0
|
29
|
+
with:
|
30
|
+
cmd: test # will run `yarn test` command
|
package/.vscode/settings.json
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
"editor.formatOnPaste": true,
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
4
|
+
"prettier.tabWidth": 4,
|
5
|
+
"prettier.useEditorConfig": true,
|
6
|
+
"prettier.configPath": "",
|
7
|
+
"prettier.requireConfig": false,
|
8
|
+
"prettier.useTabs": true,
|
9
|
+
"jest.jestCommandLine": "npx jest -i"
|
5
10
|
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
{
|
2
|
-
// Place your markdown-maker workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
3
|
-
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
4
|
-
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
5
|
-
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
6
|
-
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
2
|
+
// Place your markdown-maker workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
3
|
+
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
4
|
+
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
5
|
+
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
6
|
+
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
7
7
|
// Placeholders with the same ids are connected.
|
8
8
|
// Example:
|
9
9
|
// "Print to console": {
|
@@ -15,7 +15,7 @@
|
|
15
15
|
// ],
|
16
16
|
// "description": "Log output to console"
|
17
17
|
// }
|
18
|
-
"MD Command"
|
18
|
+
"MD Command": {
|
19
19
|
"scope": "javascript,typescript",
|
20
20
|
"prefix": "cummy",
|
21
21
|
"body": [
|
@@ -27,6 +27,4 @@
|
|
27
27
|
],
|
28
28
|
"description": "Snippet for a new command"
|
29
29
|
}
|
30
|
-
|
31
30
|
}
|
32
|
-
|
package/jest.config.js
ADDED
package/package.json
CHANGED
@@ -1,42 +1,43 @@
|
|
1
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
|
-
|
2
|
+
"name": "markdown-maker",
|
3
|
+
"version": "1.10.3",
|
4
|
+
"description": "A superset-compiler for markdown using marked",
|
5
|
+
"main": "src/main.ts",
|
6
|
+
"bin": {
|
7
|
+
"mdparse": "bundle/main.js"
|
8
|
+
},
|
9
|
+
"scripts": {
|
10
|
+
"test": "jest",
|
11
|
+
"bundle": "tsc --project tsconfig.json",
|
12
|
+
"main": "node bundle/main.js",
|
13
|
+
"clean": "rm -rf bundle bin",
|
14
|
+
"pretest": "npm run bundle"
|
15
|
+
},
|
16
|
+
"keywords": [],
|
17
|
+
"author": "blitzher",
|
18
|
+
"license": "MIT",
|
19
|
+
"dependencies": {
|
20
|
+
"argparse": "^2.0.1",
|
21
|
+
"chokidar": "^3.5.1",
|
22
|
+
"colors.ts": "^1.0.20",
|
23
|
+
"marked": "^12.0.2",
|
24
|
+
"node-html-parser": "^6.1.13",
|
25
|
+
"require-runtime": "^2.0.0",
|
26
|
+
"ts-node": "^10.9.2",
|
27
|
+
"ws": "^8.8.1"
|
28
|
+
},
|
29
|
+
"devDependencies": {
|
30
|
+
"@types/argparse": "^2.0.16",
|
31
|
+
"@types/chokidar": "^2.1.3",
|
32
|
+
"@types/colors": "^1.2.1",
|
33
|
+
"@types/jest": "^29.5.12",
|
34
|
+
"@types/node": "^15.6.1",
|
35
|
+
"@types/ws": "^8.5.3",
|
36
|
+
"@types/xregexp": "^4.4.0",
|
37
|
+
"cloc": "^2.7.0",
|
38
|
+
"jest": "^29.7.0",
|
39
|
+
"prettier": "^2.3.0",
|
40
|
+
"ts-jest": "^29.1.2",
|
41
|
+
"typescript": "^4.3.2"
|
42
|
+
}
|
42
43
|
}
|
package/src/cltool.ts
CHANGED
@@ -1,110 +1,152 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import fs from "fs"; /* for handling reading of files */
|
2
|
+
import path from "path"; /* for handling file paths */
|
3
3
|
|
4
4
|
import Colors = require("colors.ts"); /* for adding colours to strings */
|
5
|
-
import { TargetType } from "./
|
5
|
+
import { TaggedElement, TargetType } from "./types";
|
6
6
|
import Parser from "./parser";
|
7
7
|
|
8
|
+
const version = process.env.npm_package_version || "0.0.0";
|
9
|
+
|
8
10
|
Colors.enable();
|
9
11
|
import { ArgumentParser } from "argparse"; /* for parsing clargs */
|
10
|
-
|
12
|
+
import { HTMLElement } from "node-html-parser";
|
11
13
|
|
12
14
|
export const argParser = new ArgumentParser({
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
description:
|
16
|
+
"Markdown bundler, with extra options. Extension file is loaded from ./extensions.js, if it exists",
|
17
|
+
prog: "mdparse",
|
16
18
|
});
|
17
19
|
|
18
20
|
//#region command line args
|
19
21
|
argParser.add_argument("src", {
|
20
|
-
|
22
|
+
help: "file to be parsed. If this is a directory, it looks for entry point in the directory, see --entry",
|
23
|
+
});
|
24
|
+
argParser.add_argument("--version", {
|
25
|
+
action: "version",
|
26
|
+
version: `v${version}`,
|
21
27
|
});
|
22
|
-
argParser.add_argument("--version", { action: "version", version });
|
23
28
|
argParser.add_argument("-v", "--verbose", {
|
24
|
-
|
25
|
-
|
29
|
+
action: "store_true",
|
30
|
+
help: "enable verbose output",
|
26
31
|
});
|
27
32
|
argParser.add_argument("-D", "--debug", {
|
28
|
-
|
29
|
-
|
33
|
+
action: "store_true",
|
34
|
+
help: "enable debugging information",
|
30
35
|
});
|
31
36
|
argParser.add_argument("-o", "--output", {
|
32
|
-
|
33
|
-
|
37
|
+
help: "destination of bundle, by default is 'dist/bundle.md'",
|
38
|
+
default: "dist/bundle.md",
|
34
39
|
});
|
35
40
|
argParser.add_argument("-d", "--max-depth", {
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
help: "maximum recursion depth, by default is 15",
|
42
|
+
default: 15,
|
43
|
+
type: "int",
|
39
44
|
});
|
40
45
|
argParser.add_argument("-e", "--entry", {
|
41
|
-
|
42
|
-
|
46
|
+
help: "assign entry point in directory, by default is 'main.md'",
|
47
|
+
default: "main.md",
|
43
48
|
});
|
44
49
|
argParser.add_argument("-w", "--watch", {
|
45
|
-
|
46
|
-
|
50
|
+
action: "store_true",
|
51
|
+
help: "recompile after a change in target target file or directory.",
|
47
52
|
});
|
48
53
|
argParser.add_argument("-u", "--use-underscore", {
|
49
|
-
|
50
|
-
|
54
|
+
action: "store_true",
|
55
|
+
help: "set the parser to use '_' as seperator in ids for Table of Content. If the links in the table does not work, this is likely to be the issue.",
|
51
56
|
});
|
52
57
|
argParser.add_argument("-t", "--toc-level", {
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
help: "the section level of the table of contents, by default is 3",
|
59
|
+
default: 3,
|
60
|
+
type: "int",
|
56
61
|
});
|
57
62
|
argParser.add_argument("-H", "--html", {
|
58
|
-
|
59
|
-
|
63
|
+
action: "store_true",
|
64
|
+
help: "compile HTML from the parsed markdown",
|
60
65
|
});
|
61
66
|
argParser.add_argument("--allow-undefined", "-A", {
|
62
|
-
|
63
|
-
|
67
|
+
action: "store_true",
|
68
|
+
help: "allow the use of the \"<thing>\" syntax, without raising an error when 'thing' is not a variable. Mostly useful when writing inline html tags, and other non-strictly markdown related uses",
|
64
69
|
});
|
65
70
|
//#endregion
|
66
71
|
|
67
|
-
export type
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
export type CommandLineArgs = {
|
73
|
+
src: string;
|
74
|
+
output: string;
|
75
|
+
verbose: boolean;
|
76
|
+
debug: boolean;
|
77
|
+
max_depth: number;
|
78
|
+
entry: string;
|
79
|
+
watch: boolean;
|
80
|
+
use_underscore: boolean;
|
81
|
+
toc_level: number;
|
82
|
+
html: boolean;
|
83
|
+
allow_undefined: boolean;
|
84
|
+
};
|
85
|
+
|
86
|
+
export type IncompleteCommandLineArgs = {
|
87
|
+
src?: string;
|
88
|
+
output?: string;
|
89
|
+
verbose?: boolean;
|
90
|
+
debug?: boolean;
|
91
|
+
max_depth?: number;
|
92
|
+
entry?: string;
|
93
|
+
watch?: boolean;
|
94
|
+
use_underscore?: boolean;
|
95
|
+
toc_level?: number;
|
96
|
+
html?: boolean;
|
97
|
+
allow_undefined?: boolean;
|
79
98
|
};
|
80
99
|
|
81
100
|
export type ParserOptions = {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
101
|
+
defs: {
|
102
|
+
[key: string]: string;
|
103
|
+
};
|
104
|
+
secs: {
|
105
|
+
level: number;
|
106
|
+
title: string;
|
107
|
+
}[];
|
108
|
+
args: string[];
|
109
|
+
depth: number;
|
110
|
+
verbose: boolean;
|
111
|
+
debug: boolean;
|
112
|
+
max_depth: number;
|
113
|
+
use_underscore: boolean;
|
114
|
+
toc_level: number;
|
115
|
+
allow_undefined: boolean;
|
116
|
+
html: boolean;
|
117
|
+
watch: boolean;
|
118
|
+
targetType: TargetType | undefined;
|
119
|
+
only_warn: boolean;
|
120
|
+
parent?: Parser;
|
121
|
+
hooks: {
|
122
|
+
[key: string]: (map: { [tag: string]: TaggedElement }) => void;
|
123
|
+
};
|
124
|
+
isFileCallback: (s: string) => false | string;
|
125
|
+
};
|
126
|
+
|
127
|
+
export type IncompleteParserOptions = {
|
128
|
+
defs?: {
|
129
|
+
[key: string]: string;
|
130
|
+
};
|
131
|
+
secs?: {
|
132
|
+
level: number;
|
133
|
+
title: string;
|
134
|
+
}[];
|
135
|
+
args?: string[];
|
136
|
+
depth?: number;
|
137
|
+
verbose?: boolean;
|
138
|
+
debug?: boolean;
|
139
|
+
max_depth?: number;
|
140
|
+
use_underscore?: boolean;
|
141
|
+
toc_level?: number;
|
142
|
+
allow_undefined?: boolean;
|
143
|
+
html?: boolean;
|
144
|
+
watch?: boolean;
|
145
|
+
targetType?: TargetType | undefined;
|
146
|
+
only_warn?: boolean;
|
147
|
+
parent?: Parser;
|
148
|
+
hooks?: {
|
149
|
+
[key: string]: (map: { [tag: string]: TaggedElement }) => void;
|
150
|
+
};
|
151
|
+
isFileCallback?: (s: string) => false | string;
|
110
152
|
};
|