markdown-maker 1.10.0 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
- const path = require("path");
2
1
  const util = require("./tester.test.js");
3
2
 
4
3
  describe("Basic features", () => {
@@ -1,5 +1,4 @@
1
1
  const util = require("./tester.test.js");
2
- const fs = require("fs");
3
2
 
4
3
  describe("Error handling", () => {
5
4
  it("should dissallow undefined templates", () => {
package/test/hooks.js CHANGED
@@ -2,7 +2,7 @@ const fs = require("fs");
2
2
 
3
3
  exports.mochaHooks = {
4
4
  beforeEach(done) {
5
- fs.rmdirSync("test/test-files", { recursive: true });
5
+ fs.rmSync("test/test-files", { recursive: true });
6
6
  fs.mkdirSync("test/test-files");
7
7
  done();
8
8
  },
@@ -0,0 +1,114 @@
1
+ const util = require("./tester.test.js");
2
+
3
+ describe("Use of markdown hooks for SSR", () => {
4
+ it("should allow a simple hook to be used", () => {
5
+ util.put("#mdhook<test>", "sample1.md");
6
+
7
+ const parser = new util.Parser("test/test-files/sample1.md");
8
+ parser.add_hook("test", () => "hello");
9
+ const output = parser.get();
10
+
11
+ util.assert.strictEqual(output, "hello\n\n");
12
+ });
13
+ it("should allow advanced hooks to be used", () => {
14
+ util.put(
15
+ "#mdadvhook<test>\n<b>Bold</b>\n<p>Paragraph</p>\n#mdendhook",
16
+ "sample1.md"
17
+ );
18
+
19
+ const replacer = (arg) => {
20
+ const elem = new util.html.HTMLElement("p", {});
21
+ elem.set_content("complete");
22
+ return elem;
23
+ };
24
+
25
+ const parser = new util.Parser("test/test-files/sample1.md");
26
+ parser.opts.allow_undefined = true;
27
+ parser.add_adv_hook("test", replacer);
28
+ const output = parser.get();
29
+
30
+ util.assert.strictEqual(output, "<p>complete</p>\n\n");
31
+ });
32
+ it("should allow for hooks to be used in HTML", () => {
33
+ util.put("<html><body>#mdhook<test></body></html>", "sample1.html");
34
+
35
+ const parser = new util.Parser("test/test-files/sample1.html");
36
+ parser.opts.allow_undefined = true;
37
+ parser.add_hook("test", () => "hello");
38
+ const output = parser.get();
39
+
40
+ util.assert.strictEqual(output, "<html><body>hello</body></html>\n\n");
41
+ });
42
+ it("should allow for hooks to be used in HTML with advanced hooks", () => {
43
+ util.put(
44
+ "<html><body>#mdadvhook<test>\n<b>Bold</b>\n<p>Paragraph</p>\n#mdendhook</body></html>",
45
+ "sample1.html"
46
+ );
47
+
48
+ const replacer = (arg) => {
49
+ const elem = new util.html.HTMLElement("p", {});
50
+ elem.set_content("complete");
51
+ return elem;
52
+ };
53
+
54
+ const parser = new util.Parser("test/test-files/sample1.html");
55
+ parser.opts.allow_undefined = true;
56
+ parser.add_adv_hook("test", replacer);
57
+ const output = parser.get();
58
+
59
+ util.assert.strictEqual(
60
+ output,
61
+ "<html><body><p>complete</p></body></html>\n\n"
62
+ );
63
+ });
64
+ it("should allow for extracting a node from the document as a template manually with ids", () => {
65
+ util.put(
66
+ `<html><body>#mdadvhook<template><name id="b"></name><class id="p"></class>#mdendhook</body></html>`,
67
+ "sample1.html"
68
+ );
69
+
70
+ const replacer = (elem) => {
71
+ const nameElem = elem.getElementsByTagName("name")[0];
72
+ nameElem.tagName = nameElem.id;
73
+ nameElem.removeAttribute("id");
74
+ nameElem.set_content("bold");
75
+ const classElem = elem.getElementsByTagName("class")[0];
76
+ classElem.tagName = classElem.id;
77
+ classElem.removeAttribute("id");
78
+ classElem.set_content("paragraph");
79
+ return elem;
80
+ };
81
+
82
+ const parser = new util.Parser("test/test-files/sample1.html");
83
+ parser.opts.allow_undefined = true;
84
+ parser.add_adv_hook("template", replacer);
85
+ const output = parser.get();
86
+
87
+ util.assert.strictEqual(
88
+ output,
89
+ "<html><body><b>bold</b><p>paragraph</p></body></html>\n\n"
90
+ );
91
+ });
92
+ it("should allow for extracting a node from the document as a template using map and data-tags", () => {
93
+ util.put(
94
+ `<html><body>#mdadvhook<template><name data-tag="b"></name><class data-tag="p"></class>#mdendhook</body></html>`,
95
+ "sample1.html"
96
+ );
97
+
98
+ const replacer = (elem, map) => {
99
+ map["name"].set_content("bold");
100
+ map["class"].set_content("paragraph");
101
+ return elem;
102
+ };
103
+
104
+ const parser = new util.Parser("test/test-files/sample1.html");
105
+ parser.opts.allow_undefined = true;
106
+ parser.add_adv_hook("template", replacer);
107
+ const output = parser.get();
108
+
109
+ util.assert.strictEqual(
110
+ output,
111
+ "<html><body><b>bold</b><p>paragraph</p></body></html>\n\n"
112
+ );
113
+ });
114
+ });
package/test/line.test.js CHANGED
@@ -3,7 +3,7 @@ const util = require("./tester.test");
3
3
  describe("Managing blank lines", () => {
4
4
  it("should always end with 2 blank lines, even with no input", () => {
5
5
  const output = new util.Parser("").get();
6
- util.assert.strictEqual(output, "\n\n")
6
+ util.assert.strictEqual(output, "\n\n");
7
7
  });
8
8
 
9
9
  it("should reduce blank lines to 2", () => {
@@ -16,8 +16,6 @@ describe("Managing blank lines", () => {
16
16
 
17
17
  it("should allow words when removing blank lines", () => {
18
18
  const output = new util.Parser("hii\n\n\n").get();
19
- util.assert.strictEqual(output, "hii\n\n")
19
+ util.assert.strictEqual(output, "hii\n\n");
20
20
  });
21
21
  });
22
-
23
-
@@ -1,35 +1,43 @@
1
1
  const util = require("./tester.test.js");
2
2
 
3
3
  describe("Target specific functionality", () => {
4
-
5
- describe("HTML", () => {
6
- it("Should include `#mdlabel` command, when compiling HTML", () => {
7
- const parser = new util.Parser("#mdlabel<0,Cool!>");
8
- const html = parser.get(util.TargetType.HTML);
9
-
10
- util.assert.strictEqual(html, '<span id="cool"></span>\n\n')
11
- });
12
-
13
- it("Should link to sections with #mdref", () => {
14
- const parser = new util.Parser("#mdlabel<0,Cool!>\n#mdlabel<1,coolzz>\n#mdref<Cool!>");
15
- const html = parser.get(util.TargetType.HTML);
16
-
17
- util.assert.strictEqual(html, '<span id="cool"></span>\n<span id="coolzz"></span>\n<a href="#cool">Cool!</a>\n\n');
18
- })
19
- });
20
-
21
- describe("Markdown", () => {
22
- it("Should not include `#mdlabel` command, when compiling Markdown", () => {
23
- const parser = new util.Parser("#mdlabel<0,Cool!>");
24
-
25
- const md = parser.get(util.TargetType.MARKDOWN);
26
- util.assert.strictEqual(md, '\n\n')
27
- });
28
- it("Should include #mdref to title elements in markdown", () => {
29
- const output = new util.Parser("# Some Title!\n#mdref<Some Title!>").get();
30
-
31
- util.assert.strictEqual(output, '# Some Title!\n[Some Title!](#some-title)\n\n')
32
- });
33
-
34
- })
35
- });
4
+ describe("HTML", () => {
5
+ it("Should include `#mdlabel` command, when compiling HTML", () => {
6
+ const parser = new util.Parser("#mdlabel<0,Cool!>");
7
+ const html = parser.get(util.TargetType.HTML);
8
+
9
+ util.assert.strictEqual(html, '<span id="cool"></span>\n\n');
10
+ });
11
+
12
+ it("Should link to sections with #mdref", () => {
13
+ const parser = new util.Parser(
14
+ "#mdlabel<0,Cool!>\n#mdlabel<1,coolzz>\n#mdref<Cool!>"
15
+ );
16
+ const html = parser.get(util.TargetType.HTML);
17
+
18
+ util.assert.strictEqual(
19
+ html,
20
+ '<span id="cool"></span>\n<span id="coolzz"></span>\n<a href="#cool">Cool!</a>\n\n'
21
+ );
22
+ });
23
+ });
24
+
25
+ describe("Markdown", () => {
26
+ it("Should not include `#mdlabel` command, when compiling Markdown", () => {
27
+ const parser = new util.Parser("#mdlabel<0,Cool!>");
28
+
29
+ const md = parser.get(util.TargetType.MARKDOWN);
30
+ util.assert.strictEqual(md, "\n\n");
31
+ });
32
+ it("Should include #mdref to title elements in markdown", () => {
33
+ const output = new util.Parser(
34
+ "# Some Title!\n#mdref<Some Title!>"
35
+ ).get();
36
+
37
+ util.assert.strictEqual(
38
+ output,
39
+ "# Some Title!\n[Some Title!](#some-title)\n\n"
40
+ );
41
+ });
42
+ });
43
+ });
@@ -1,7 +1,8 @@
1
1
  const fs = require("fs");
2
2
  const assert = require("assert");
3
- const Parser = require("../build/parse");
3
+ const Parser = require("../bundle/parser");
4
4
  const path = require("path");
5
+ const html = require("node-html-parser");
5
6
 
6
7
  /* make folder for temporary files, if it doesn't exist */
7
8
  if (
@@ -29,8 +30,9 @@ const TargetType = {
29
30
  };
30
31
 
31
32
  module.exports = {
32
- fs,
33
33
  assert,
34
+ fs,
35
+ html,
34
36
  path,
35
37
  Parser,
36
38
  put,
package/test/vars.test.js CHANGED
@@ -1,57 +1,49 @@
1
- const util = require("./tester.test");
1
+ const util = require("./tester.test.js");
2
2
 
3
3
  describe("Use variables", () => {
4
- it('should replace var with the value', () => {
4
+ it("should replace var with the value", () => {
5
5
  const output = new util.Parser("#mddef<hi=yo>\n#mdvar<hi>").get();
6
6
 
7
- util.assert.strictEqual(output, "\nyo\n\n")
7
+ util.assert.strictEqual(output, "\nyo\n\n");
8
8
  });
9
- it('should use variable shorthand', () => {
9
+ it("should use variable shorthand", () => {
10
10
  const output = new util.Parser("#mddef<hi=yo>\n<hi>").get();
11
11
 
12
- util.assert.strictEqual(output, "\nyo\n\n")
12
+ util.assert.strictEqual(output, "\nyo\n\n");
13
13
  });
14
- it('should use variables across files', () => {
14
+ it("should use variables across files", () => {
15
15
  util.put("#mddef<hi=yo>\n#mdinclude<sample2.md>", "sample1.md");
16
16
  util.put("<hi>", "sample2.md");
17
17
 
18
18
  const output = new util.Parser("test/test-files/sample1.md").get();
19
19
 
20
- util.assert.strictEqual(output, "\nyo\n\n")
21
- })
22
- it('should throw if undefined variable', () => {
23
-
20
+ util.assert.strictEqual(output, "\nyo\n\n");
21
+ });
22
+ it("should throw if undefined variable", () => {
24
23
  const parser = new util.Parser("<yo>");
25
24
 
26
25
  let e;
27
26
  /* should throw an error */
28
- util.assert.throws(
29
- () => {
30
- try {
31
- parser.get();
32
- } catch (_e) {
33
- e = _e;
34
- throw _e;
35
- }
27
+ util.assert.throws(() => {
28
+ try {
29
+ parser.get();
30
+ } catch (_e) {
31
+ e = _e;
32
+ throw _e;
36
33
  }
37
- );
38
-
39
-
40
-
34
+ });
41
35
  });
42
36
 
43
- it('should preserve whatever comes after', () => {
37
+ it("should preserve whatever comes after", () => {
44
38
  const output = new util.Parser("#mddef<hi=yo>\n<hi>,").get();
45
39
  util.assert.strictEqual(output, "\nyo,\n\n");
46
40
  });
47
41
 
48
- it('should replace underscore with space', () => {
49
- const output = new util.Parser("#mddef<name=Mr_Sir>\n#mdvar<name>").get();
42
+ it("should replace underscore with space", () => {
43
+ const output = new util.Parser(
44
+ "#mddef<name=Mr_Sir>\n#mdvar<name>"
45
+ ).get();
50
46
 
51
- util.assert.strictEqual(output, "\nMr Sir\n\n")
47
+ util.assert.strictEqual(output, "\nMr Sir\n\n");
52
48
  });
53
-
54
49
  });
55
-
56
-
57
-
package/tsconfig.json CHANGED
@@ -14,9 +14,9 @@
14
14
  // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
15
15
  "declaration": true /* Generates corresponding '.d.ts' file. */,
16
16
  // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
17
- "sourceMap": true, /* Generates corresponding '.map' file. */
17
+ "sourceMap": true /* Generates corresponding '.map' file. */,
18
18
  // "outFile": "./", /* Concatenate and emit output to single file. */
19
- "outDir": "./build" /* Redirect output structure to the directory. */,
19
+ "outDir": "./bundle" /* Redirect output structure to the directory. */,
20
20
  // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
21
21
  // "composite": true, /* Enable project compilation */
22
22
  // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
package/build/cltool.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const argParser: any;
package/build/cltool.js DELETED
@@ -1,161 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.argParser = void 0;
7
- var fs = require("fs"); /* for handling reading of files */
8
- var path = require("path"); /* for handling file paths */
9
- var Colors = require("colors.ts"); /* for adding colours to strings */
10
- var parse_1 = __importDefault(require("./parse"));
11
- var ws_1 = require("ws");
12
- Colors.enable();
13
- var ArgumentParser = require("argparse").ArgumentParser; /* for parsing clargs */
14
- var version = require("../package.json").version; /* package version number */
15
- var choki = require("chokidar");
16
- exports.argParser = new ArgumentParser({
17
- description: "Markdown bundler, with extra options. Extension file is loaded from ./extensions.js, if it exists",
18
- prog: "mdparse",
19
- });
20
- var configFileName = ".mdmconfig.json";
21
- //#region command line args
22
- exports.argParser.add_argument("src", {
23
- help: "file to be parsed. If this is a directory, it looks for entry point in the directory, see --entry",
24
- });
25
- exports.argParser.add_argument("--version", { action: "version", version: version });
26
- exports.argParser.add_argument("-v", "--verbose", {
27
- action: "store_true",
28
- help: "enable verbose output",
29
- });
30
- exports.argParser.add_argument("-D", "--debug", {
31
- action: "store_true",
32
- help: "enable debugging information",
33
- });
34
- exports.argParser.add_argument("-o", "--output", {
35
- help: "destination of bundle, by default is 'dist/bundle.md'",
36
- default: "dist/bundle.md",
37
- });
38
- exports.argParser.add_argument("-d", "--max-depth", {
39
- help: "maximum recursion depth, by default is 15",
40
- default: 15,
41
- type: "int",
42
- });
43
- exports.argParser.add_argument("-e", "--entry", {
44
- help: "assign entry point in directory, by default is 'main.md'",
45
- default: "main.md",
46
- });
47
- exports.argParser.add_argument("-w", "--watch", {
48
- action: "store_true",
49
- help: "recompile after a change in target target file or directory.",
50
- });
51
- exports.argParser.add_argument("-u", "--use-underscore", {
52
- action: "store_true",
53
- 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.",
54
- });
55
- exports.argParser.add_argument("-t", "--toc-level", {
56
- help: "the section level of the table of contents, by default is 3",
57
- default: 3,
58
- type: "int",
59
- });
60
- exports.argParser.add_argument("-H", "--html", {
61
- action: "store_true",
62
- help: "compile HTML from the parsed markdown",
63
- });
64
- exports.argParser.add_argument("--allow-undefined", "-A", {
65
- action: "store_true",
66
- 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",
67
- });
68
- //#endregion
69
- function main() {
70
- var clargs, fileargs;
71
- var server;
72
- /* Read config file or parse args from cmd-line */
73
- if (fs.existsSync(configFileName)) {
74
- var data = JSON.parse(fs.readFileSync(configFileName)).opts;
75
- var args_1 = [];
76
- Object.entries(data).forEach(function (_a) {
77
- var key = _a[0], value = _a[1];
78
- if (key != "src" && value !== false) {
79
- args_1.push("--" + key);
80
- }
81
- if (typeof value != "boolean") {
82
- args_1.push(value);
83
- }
84
- });
85
- /* We skip [0] and [1], as it is the binary and source file, even when compiled*/
86
- for (var i = 2; i < process.argv.length; i++)
87
- args_1.push(process.argv[i]);
88
- clargs = exports.argParser.parse_args(args_1);
89
- }
90
- else {
91
- clargs = exports.argParser.parse_args();
92
- }
93
- /* if src is init, create config file and exit */
94
- if (clargs.src == "init") {
95
- var template = fs.readFileSync(path.join(__dirname, "..", "src", "templates", "configTemplate.json"));
96
- fs.writeFileSync(configFileName, template);
97
- fs.writeFileSync("main.md", "# Main\n");
98
- return;
99
- }
100
- /* helper method for calling parser */
101
- var compile = function (source, output, cb) {
102
- /* load data from file, if it exists,
103
- * otherwise, interpret as string */
104
- var parser = new parse_1.default(source, clargs);
105
- parser.to(output, function (file) {
106
- console.log("Compiled ".concat(file).green);
107
- if (cb)
108
- cb();
109
- });
110
- return parser;
111
- };
112
- var internalCooldown = 1000;
113
- function watcher(event, path) {
114
- var now = Date.now();
115
- if (!this.time)
116
- this.time = now;
117
- if (now - this.time < internalCooldown)
118
- return;
119
- console.log(path);
120
- console.log("Detected change in ".concat(path, "..."));
121
- try {
122
- compile(clargs.src, clargs.output, function () {
123
- /* after compile, send refresh command to clients */
124
- server.clients.forEach(function (client) {
125
- if (client.OPEN)
126
- client.send("refresh");
127
- });
128
- });
129
- }
130
- catch (e) {
131
- console.log(e.message);
132
- }
133
- this.time = now;
134
- }
135
- /* in case source is a directory, look for entry in directory */
136
- if (fs.existsSync(clargs.src) && fs.lstatSync(clargs.src).isDirectory()) {
137
- clargs.src = path.join(clargs.src, clargs.entry);
138
- }
139
- if (clargs.debug)
140
- console.dir(clargs);
141
- /* compile once */
142
- if (!clargs.watch)
143
- compile(clargs.src, clargs.output);
144
- /* watch the folder and recompile on change */
145
- else {
146
- var srcDirName = path.dirname(clargs.src);
147
- console.log("Watching ".concat(srcDirName, " for changes...").yellow);
148
- server = new ws_1.WebSocketServer({ port: 7788 });
149
- var _watcher = choki.watch(srcDirName).on("all", watcher);
150
- try {
151
- compile(clargs.src, clargs.output);
152
- }
153
- catch (e) {
154
- console.log(e.message);
155
- }
156
- }
157
- }
158
- /* main entrypoint */
159
- if (require.main === module)
160
- main();
161
- //# sourceMappingURL=cltool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cltool.js","sourceRoot":"","sources":["../src/cltool.ts"],"names":[],"mappings":";;;;;;AAAA,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,mCAAmC;AAC7D,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,6BAA6B;AAE3D,kCAAqC,CAAC,mCAAmC;AACzE,kDAA6B;AAC7B,yBAAqC;AAErC,MAAM,CAAC,MAAM,EAAE,CAAC;AACR,IAAA,cAAc,GAAK,OAAO,CAAC,UAAU,CAAC,eAAxB,CAAyB,CAAC,wBAAwB;AAChE,IAAA,OAAO,GAAK,OAAO,CAAC,iBAAiB,CAAC,QAA/B,CAAgC,CAAC,4BAA4B;AAC5E,IAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAErB,QAAA,SAAS,GAAG,IAAI,cAAc,CAAC;IACxC,WAAW,EAAE,mGAAmG;IAChH,IAAI,EAAE,SAAS;CAClB,CAAC,CAAC;AAEH,IAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,2BAA2B;AAC3B,iBAAS,CAAC,YAAY,CAAC,KAAK,EAAE;IAC1B,IAAI,EAAE,mGAAmG;CAC5G,CAAC,CAAC;AACH,iBAAS,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE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qBAAqB;AACrB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAI,EAAE,CAAC"}
@@ -1,43 +0,0 @@
1
- import Parser from "./parse";
2
- export declare class MDMError extends Error {
3
- match: RegExpMatchArray;
4
- constructor(message: string, match: RegExpMatchArray);
5
- }
6
- export declare const commands: {
7
- preparse: Command[];
8
- parse: Command[];
9
- postparse: Command[];
10
- };
11
- export declare enum CommandType {
12
- PREPARSE = 0,
13
- PARSE = 1,
14
- POSTPARSE = 2
15
- }
16
- export declare enum TargetType {
17
- HTML = 0,
18
- MARKDOWN = 1
19
- }
20
- export declare class Command {
21
- validator: RegExp;
22
- acter: (match: RegExpMatchArray, parser: Parser) => string | void;
23
- type: CommandType;
24
- constructor(validator: RegExp, acter: (match: RegExpMatchArray, parser: Parser) => string | void, type: CommandType);
25
- act(match: any, parser: any): string | void;
26
- }
27
- export declare function load_extensions(parser: Parser): void;
28
- /**
29
- *
30
- * @param regex The regex to match the command
31
- * @param acter The function called when a match is found. Takes two arguments, `match` and `parser`. `match` is the result of the regex match, and `parser` is the parser instance. The function should return the replacement string.
32
- * @param type When the command should be run. Can be `CommandType.PREPARSE`, `CommandType.PARSE`, or `CommandType.POSTPARSE`. Defaults to `CommandType.PARSE`.
33
- */
34
- export declare function new_command(regex: RegExp, acter: (match: RegExpMatchArray, parser: Parser) => string, type?: CommandType): void;
35
- declare const _default: {
36
- commands: {
37
- preparse: Command[];
38
- parse: Command[];
39
- postparse: Command[];
40
- };
41
- load_extensions: typeof load_extensions;
42
- };
43
- export default _default;