markdown-maker 1.10.2 → 1.10.4
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/bundle/cltool.d.ts +86 -0
- package/bundle/cltool.js +63 -0
- package/bundle/cltool.js.map +1 -0
- package/bundle/commands.d.ts +23 -0
- package/bundle/commands.js +303 -0
- package/bundle/commands.js.map +1 -0
- package/bundle/errors.d.ts +11 -0
- package/bundle/errors.js +51 -0
- package/bundle/errors.js.map +1 -0
- package/bundle/main.d.ts +6 -0
- package/bundle/main.js +152 -0
- package/bundle/main.js.map +1 -0
- package/bundle/parser.d.ts +35 -0
- package/bundle/parser.js +330 -0
- package/bundle/parser.js.map +1 -0
- package/bundle/templates/mathjax.d.ts +2 -0
- package/bundle/templates/mathjax.js +3 -0
- package/bundle/templates/mathjax.js.map +1 -0
- package/bundle/templates/presentation.d.ts +2 -0
- package/bundle/templates/presentation.js +3 -0
- package/bundle/templates/presentation.js.map +1 -0
- package/bundle/templates.d.ts +10 -0
- package/bundle/templates.js +23 -0
- package/bundle/templates.js.map +1 -0
- package/bundle/types.d.ts +28 -0
- package/bundle/types.js +15 -0
- package/bundle/types.js.map +1 -0
- package/bundle/version.d.ts +1 -0
- package/bundle/version.js +5 -0
- package/bundle/version.js.map +1 -0
- package/jest.config.js +7 -0
- package/package.json +42 -40
- package/src/cltool.ts +115 -72
- package/src/commands.ts +257 -241
- package/src/errors.ts +26 -0
- package/src/main.ts +114 -109
- package/src/parser.ts +378 -350
- package/src/templates.ts +5 -1
- package/src/types.ts +33 -0
- package/src/version.ts +1 -0
- package/tests/_test-util.ts +44 -0
- package/tests/advanced.spec.ts +102 -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
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.new_template = void 0;
|
4
|
+
var errors_1 = require("./errors");
|
5
|
+
var templates = {};
|
6
|
+
/**
|
7
|
+
* Function to add a template to the templates object. Similar to definitions and variables, but reside as an extension.
|
8
|
+
* @param name The name of the template
|
9
|
+
* @param content The replacement string
|
10
|
+
*/
|
11
|
+
function new_template(name, content) {
|
12
|
+
if (name in templates)
|
13
|
+
throw new errors_1.MDMNonParserError("Template \"".concat(name, "\" already exists"));
|
14
|
+
templates[name] = content;
|
15
|
+
}
|
16
|
+
exports.new_template = new_template;
|
17
|
+
/* initialize default templates */
|
18
|
+
var presentation_template = require("../src/templates/presentation.js");
|
19
|
+
var mathjax_template = require("../src/templates/mathjax.js");
|
20
|
+
new_template("presentation", presentation_template);
|
21
|
+
new_template("mathjax", mathjax_template);
|
22
|
+
exports.default = templates;
|
23
|
+
//# sourceMappingURL=templates.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":";;;AAAA,mCAAuD;AAEvD,IAAM,SAAS,GAA8B,EAAE,CAAC;AAEhD;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAe;IACzD,IAAI,IAAI,IAAI,SAAS;QACpB,MAAM,IAAI,0BAAiB,CAAC,qBAAa,IAAI,sBAAkB,CAAC,CAAC;IAClE,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AAC3B,CAAC;AAJD,oCAIC;AAED,kCAAkC;AAClC,IAAM,qBAAqB,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC1E,IAAM,gBAAgB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAChE,YAAY,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;AACpD,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAE1C,kBAAe,SAAS,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { HTMLElement } from "node-html-parser";
|
2
|
+
import { Command } from "./commands";
|
3
|
+
export type CommandGroupType = {
|
4
|
+
preparse: Command[];
|
5
|
+
parse: Command[];
|
6
|
+
postparse: Command[];
|
7
|
+
};
|
8
|
+
type TaggedElementArguments = {
|
9
|
+
repeat?: number;
|
10
|
+
};
|
11
|
+
export type TaggedElement = {
|
12
|
+
"html-tag": string;
|
13
|
+
"var-tag": string;
|
14
|
+
_raw: string;
|
15
|
+
args: TaggedElementArguments;
|
16
|
+
node: HTMLElement;
|
17
|
+
};
|
18
|
+
export declare enum CommandType {
|
19
|
+
PREPARSE = 0,
|
20
|
+
PARSE = 1,
|
21
|
+
POSTPARSE = 2
|
22
|
+
}
|
23
|
+
export declare enum TargetType {
|
24
|
+
HTML = 0,
|
25
|
+
MARKDOWN = 1
|
26
|
+
}
|
27
|
+
export type Checksum = string;
|
28
|
+
export {};
|
package/bundle/types.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TargetType = exports.CommandType = void 0;
|
4
|
+
var CommandType;
|
5
|
+
(function (CommandType) {
|
6
|
+
CommandType[CommandType["PREPARSE"] = 0] = "PREPARSE";
|
7
|
+
CommandType[CommandType["PARSE"] = 1] = "PARSE";
|
8
|
+
CommandType[CommandType["POSTPARSE"] = 2] = "POSTPARSE";
|
9
|
+
})(CommandType = exports.CommandType || (exports.CommandType = {}));
|
10
|
+
var TargetType;
|
11
|
+
(function (TargetType) {
|
12
|
+
TargetType[TargetType["HTML"] = 0] = "HTML";
|
13
|
+
TargetType[TargetType["MARKDOWN"] = 1] = "MARKDOWN";
|
14
|
+
})(TargetType = exports.TargetType || (exports.TargetType = {}));
|
15
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAqBA,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,qDAAQ,CAAA;IACR,+CAAK,CAAA;IACL,uDAAS,CAAA;AACV,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACrB,2CAAI,CAAA;IACJ,mDAAQ,CAAA;AACT,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const LIB_VERSION = "1.10.3";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,QAAQ,CAAC"}
|
package/jest.config.js
ADDED
package/package.json
CHANGED
@@ -1,42 +1,44 @@
|
|
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.4",
|
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
|
+
"prebundle": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
|
11
|
+
"test": "jest",
|
12
|
+
"bundle": "tsc --project tsconfig.json",
|
13
|
+
"main": "node bundle/main.js",
|
14
|
+
"clean": "rm -rf bundle bin",
|
15
|
+
"pretest": "npm run bundle"
|
16
|
+
},
|
17
|
+
"keywords": [],
|
18
|
+
"author": "blitzher",
|
19
|
+
"license": "MIT",
|
20
|
+
"dependencies": {
|
21
|
+
"argparse": "^2.0.1",
|
22
|
+
"chokidar": "^3.5.1",
|
23
|
+
"colors.ts": "^1.0.20",
|
24
|
+
"marked": "^12.0.2",
|
25
|
+
"node-html-parser": "^6.1.13",
|
26
|
+
"require-runtime": "^2.0.0",
|
27
|
+
"ts-node": "^10.9.2",
|
28
|
+
"ws": "^8.8.1"
|
29
|
+
},
|
30
|
+
"devDependencies": {
|
31
|
+
"@types/argparse": "^2.0.16",
|
32
|
+
"@types/chokidar": "^2.1.3",
|
33
|
+
"@types/colors": "^1.2.1",
|
34
|
+
"@types/jest": "^29.5.12",
|
35
|
+
"@types/node": "^15.6.1",
|
36
|
+
"@types/ws": "^8.5.3",
|
37
|
+
"@types/xregexp": "^4.4.0",
|
38
|
+
"cloc": "^2.7.0",
|
39
|
+
"jest": "^29.7.0",
|
40
|
+
"prettier": "^2.3.0",
|
41
|
+
"ts-jest": "^29.1.2",
|
42
|
+
"typescript": "^4.3.2"
|
43
|
+
}
|
42
44
|
}
|
package/src/cltool.ts
CHANGED
@@ -1,110 +1,153 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import fs from "fs"; /* for handling reading of files */
|
2
|
+
import path from "path"; /* for handling file paths */
|
3
3
|
|
4
|
-
|
5
|
-
import { TargetType } from "./
|
4
|
+
const Colors = require("colors.ts"); /* for adding colours to strings */
|
5
|
+
import { TaggedElement, TargetType } from "./types";
|
6
|
+
import { LIB_VERSION } from "./version";
|
6
7
|
import Parser from "./parser";
|
7
8
|
|
9
|
+
const version = LIB_VERSION;
|
10
|
+
|
8
11
|
Colors.enable();
|
9
12
|
import { ArgumentParser } from "argparse"; /* for parsing clargs */
|
10
|
-
|
13
|
+
import { HTMLElement } from "node-html-parser";
|
11
14
|
|
12
15
|
export const argParser = new ArgumentParser({
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
description:
|
17
|
+
"Markdown bundler, with extra options. Extension file is loaded from ./extensions.js, if it exists",
|
18
|
+
prog: "mdparse",
|
16
19
|
});
|
17
20
|
|
18
21
|
//#region command line args
|
19
22
|
argParser.add_argument("src", {
|
20
|
-
|
23
|
+
help: "file to be parsed. If this is a directory, it looks for entry point in the directory, see --entry",
|
24
|
+
});
|
25
|
+
argParser.add_argument("--version", {
|
26
|
+
action: "version",
|
27
|
+
version: `v${version}`,
|
21
28
|
});
|
22
|
-
argParser.add_argument("--version", { action: "version", version });
|
23
29
|
argParser.add_argument("-v", "--verbose", {
|
24
|
-
|
25
|
-
|
30
|
+
action: "store_true",
|
31
|
+
help: "enable verbose output",
|
26
32
|
});
|
27
33
|
argParser.add_argument("-D", "--debug", {
|
28
|
-
|
29
|
-
|
34
|
+
action: "store_true",
|
35
|
+
help: "enable debugging information",
|
30
36
|
});
|
31
37
|
argParser.add_argument("-o", "--output", {
|
32
|
-
|
33
|
-
|
38
|
+
help: "destination of bundle, by default is 'dist/bundle.md'",
|
39
|
+
default: "dist/bundle.md",
|
34
40
|
});
|
35
41
|
argParser.add_argument("-d", "--max-depth", {
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
help: "maximum recursion depth, by default is 15",
|
43
|
+
default: 15,
|
44
|
+
type: "int",
|
39
45
|
});
|
40
46
|
argParser.add_argument("-e", "--entry", {
|
41
|
-
|
42
|
-
|
47
|
+
help: "assign entry point in directory, by default is 'main.md'",
|
48
|
+
default: "main.md",
|
43
49
|
});
|
44
50
|
argParser.add_argument("-w", "--watch", {
|
45
|
-
|
46
|
-
|
51
|
+
action: "store_true",
|
52
|
+
help: "recompile after a change in target target file or directory.",
|
47
53
|
});
|
48
54
|
argParser.add_argument("-u", "--use-underscore", {
|
49
|
-
|
50
|
-
|
55
|
+
action: "store_true",
|
56
|
+
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
57
|
});
|
52
58
|
argParser.add_argument("-t", "--toc-level", {
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
help: "the section level of the table of contents, by default is 3",
|
60
|
+
default: 3,
|
61
|
+
type: "int",
|
56
62
|
});
|
57
63
|
argParser.add_argument("-H", "--html", {
|
58
|
-
|
59
|
-
|
64
|
+
action: "store_true",
|
65
|
+
help: "compile HTML from the parsed markdown",
|
60
66
|
});
|
61
67
|
argParser.add_argument("--allow-undefined", "-A", {
|
62
|
-
|
63
|
-
|
68
|
+
action: "store_true",
|
69
|
+
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
70
|
});
|
65
71
|
//#endregion
|
66
72
|
|
67
|
-
export type
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
export type CommandLineArgs = {
|
74
|
+
src: string;
|
75
|
+
output: string;
|
76
|
+
verbose: boolean;
|
77
|
+
debug: boolean;
|
78
|
+
max_depth: number;
|
79
|
+
entry: string;
|
80
|
+
watch: boolean;
|
81
|
+
use_underscore: boolean;
|
82
|
+
toc_level: number;
|
83
|
+
html: boolean;
|
84
|
+
allow_undefined: boolean;
|
85
|
+
};
|
86
|
+
|
87
|
+
export type IncompleteCommandLineArgs = {
|
88
|
+
src?: string;
|
89
|
+
output?: string;
|
90
|
+
verbose?: boolean;
|
91
|
+
debug?: boolean;
|
92
|
+
max_depth?: number;
|
93
|
+
entry?: string;
|
94
|
+
watch?: boolean;
|
95
|
+
use_underscore?: boolean;
|
96
|
+
toc_level?: number;
|
97
|
+
html?: boolean;
|
98
|
+
allow_undefined?: boolean;
|
79
99
|
};
|
80
100
|
|
81
101
|
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
|
-
|
102
|
+
defs: {
|
103
|
+
[key: string]: string;
|
104
|
+
};
|
105
|
+
secs: {
|
106
|
+
level: number;
|
107
|
+
title: string;
|
108
|
+
}[];
|
109
|
+
args: string[];
|
110
|
+
depth: number;
|
111
|
+
verbose: boolean;
|
112
|
+
debug: boolean;
|
113
|
+
max_depth: number;
|
114
|
+
use_underscore: boolean;
|
115
|
+
toc_level: number;
|
116
|
+
allow_undefined: boolean;
|
117
|
+
html: boolean;
|
118
|
+
watch: boolean;
|
119
|
+
targetType: TargetType | undefined;
|
120
|
+
only_warn: boolean;
|
121
|
+
parent?: Parser;
|
122
|
+
hooks: {
|
123
|
+
[key: string]: (map: { [tag: string]: TaggedElement }) => void;
|
124
|
+
};
|
125
|
+
isFileCallback: (s: string) => false | string;
|
126
|
+
};
|
127
|
+
|
128
|
+
export type IncompleteParserOptions = {
|
129
|
+
defs?: {
|
130
|
+
[key: string]: string;
|
131
|
+
};
|
132
|
+
secs?: {
|
133
|
+
level: number;
|
134
|
+
title: string;
|
135
|
+
}[];
|
136
|
+
args?: string[];
|
137
|
+
depth?: number;
|
138
|
+
verbose?: boolean;
|
139
|
+
debug?: boolean;
|
140
|
+
max_depth?: number;
|
141
|
+
use_underscore?: boolean;
|
142
|
+
toc_level?: number;
|
143
|
+
allow_undefined?: boolean;
|
144
|
+
html?: boolean;
|
145
|
+
watch?: boolean;
|
146
|
+
targetType?: TargetType | undefined;
|
147
|
+
only_warn?: boolean;
|
148
|
+
parent?: Parser;
|
149
|
+
hooks?: {
|
150
|
+
[key: string]: (map: { [tag: string]: TaggedElement }) => void;
|
151
|
+
};
|
152
|
+
isFileCallback?: (s: string) => false | string;
|
110
153
|
};
|