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.
@@ -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: Mocha
4
+ name: Jest
5
5
 
6
6
  on: [push, pull_request]
7
7
 
8
8
  jobs:
9
- build:
9
+ build:
10
+ runs-on: ubuntu-latest
10
11
 
11
- runs-on: ubuntu-latest
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
- strategy:
14
- matrix:
15
- node-version: [16.x, 18.x, 20.x]
16
- # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
17
-
18
- steps:
19
- - uses: actions/checkout@v2
20
- - name: Use Node.js ${{ matrix.node-version }}
21
- uses: actions/setup-node@v1
22
- with:
23
- node-version: ${{ matrix.node-version }}
24
- - name: yarn install
25
- uses: borales/actions-yarn@v3.0.0
26
- with:
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
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["orta.vscode-jest", "github.vscode-github-actions"]
3
+ }
@@ -1,5 +1,10 @@
1
1
  {
2
- "editor.formatOnPaste": true,
3
- "editor.defaultFormatter": "esbenp.prettier-vscode",
4
- "prettier.tabWidth": 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
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ transform: { "^.+\\.ts?$": "ts-jest" },
3
+ testEnvironment: "node",
4
+ testRegex: "/tests/.*\\.(test|spec)?\\.(ts|tsx)$",
5
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
6
+ maxWorkers: 1,
7
+ };
package/package.json CHANGED
@@ -1,42 +1,43 @@
1
1
  {
2
- "name": "markdown-maker",
3
- "version": "1.10.2",
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": "mocha --require test/hooks.js",
11
- "test:yarn": "mocha",
12
- "bundle": "tsc --project tsconfig.json",
13
- "main": "node bundle/main.js document/main.md -o dist/bundle.md --debug",
14
- "debug": "node src/main.js -db document/main.md -o dist/bundle.md",
15
- "clear": "rm -rf bundle bin",
16
- "pretest": "npm run bundle",
17
- "pretest:yarn": "yarn bundle"
18
- },
19
- "keywords": [],
20
- "author": "blitzher",
21
- "license": "MIT",
22
- "dependencies": {
23
- "argparse": "^2.0.1",
24
- "chokidar": "^3.5.1",
25
- "colors.ts": "^1.0.20",
26
- "marked": "^2.0.1",
27
- "node-html-parser": "^6.1.13",
28
- "require-runtime": "^2.0.0",
29
- "ws": "^8.8.1"
30
- },
31
- "devDependencies": {
32
- "@types/argparse": "^2.0.16",
33
- "@types/chokidar": "^2.1.3",
34
- "@types/colors": "^1.2.1",
35
- "@types/node": "^15.6.1",
36
- "@types/ws": "^8.5.3",
37
- "cloc": "^2.7.0",
38
- "mocha": "^8.3.1",
39
- "prettier": "^2.3.0",
40
- "typescript": "^4.3.2"
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
- const fs = require("fs"); /* for handling reading of files */
2
- const path = require("path"); /* for handling file paths */
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 "./commands";
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
- const { version } = require("../package.json"); /* package version number */
12
+ import { HTMLElement } from "node-html-parser";
11
13
 
12
14
  export const argParser = new ArgumentParser({
13
- description:
14
- "Markdown bundler, with extra options. Extension file is loaded from ./extensions.js, if it exists",
15
- prog: "mdparse",
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
- help: "file to be parsed. If this is a directory, it looks for entry point in the directory, see --entry",
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
- action: "store_true",
25
- help: "enable verbose output",
29
+ action: "store_true",
30
+ help: "enable verbose output",
26
31
  });
27
32
  argParser.add_argument("-D", "--debug", {
28
- action: "store_true",
29
- help: "enable debugging information",
33
+ action: "store_true",
34
+ help: "enable debugging information",
30
35
  });
31
36
  argParser.add_argument("-o", "--output", {
32
- help: "destination of bundle, by default is 'dist/bundle.md'",
33
- default: "dist/bundle.md",
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
- help: "maximum recursion depth, by default is 15",
37
- default: 15,
38
- type: "int",
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
- help: "assign entry point in directory, by default is 'main.md'",
42
- default: "main.md",
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
- action: "store_true",
46
- help: "recompile after a change in target target file or directory.",
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
- action: "store_true",
50
- 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
+ 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
- help: "the section level of the table of contents, by default is 3",
54
- default: 3,
55
- type: "int",
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
- action: "store_true",
59
- help: "compile HTML from the parsed markdown",
63
+ action: "store_true",
64
+ help: "compile HTML from the parsed markdown",
60
65
  });
61
66
  argParser.add_argument("--allow-undefined", "-A", {
62
- action: "store_true",
63
- 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
+ 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 CLArgs = {
68
- src: string;
69
- output: string;
70
- verbose: boolean;
71
- debug: boolean;
72
- max_depth: number;
73
- entry: string;
74
- watch: boolean;
75
- use_underscore: boolean;
76
- toc_level: number;
77
- html: boolean;
78
- allow_undefined: boolean;
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
- defs: {
83
- [key: string]: string;
84
- };
85
- secs: {
86
- level: number;
87
- title: string;
88
- }[];
89
- args: string[];
90
- depth: number;
91
- verbose: boolean;
92
- debug: boolean;
93
- max_depth: number;
94
- use_underscore: boolean;
95
- toc_level: number;
96
- allow_undefined: boolean;
97
- html: boolean;
98
- watch: boolean;
99
- targetType: TargetType | undefined;
100
- only_warn: boolean;
101
- parent?: Parser;
102
- hooks: { [key: string]: () => string };
103
- adv_hooks: {
104
- [key: string]: (
105
- tree: HTMLElement,
106
- map: { [tag: string]: HTMLElement }
107
- ) => HTMLElement;
108
- };
109
- isFileCallback: (s: string) => false | string;
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
  };