markdown-to-html-cli 3.4.16 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/lib/cli.js.map +1 -1
- package/lib/create.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -1
- package/lib/nodes/copy.js +10 -10
- package/package.json +3 -3
- package/src/cli.ts +1 -1
- package/src/create.ts +7 -7
- package/src/index.ts +21 -4
- package/src/nodes/copy.ts +10 -10
- package/src/utils.ts +1 -1
package/README.md
CHANGED
|
@@ -137,6 +137,7 @@ Options:
|
|
|
137
137
|
--keywords Define keywords for search engines.
|
|
138
138
|
--no-dark-mode Disable light and dark theme styles button.
|
|
139
139
|
--markdown Markdown string.
|
|
140
|
+
--style Override default styles. css file path or css string.
|
|
140
141
|
--markdown-style-theme Setting markdown-style light/dark theme.
|
|
141
142
|
--output, -o Output static pages to the specified directory. Default: "index.html"
|
|
142
143
|
--source, -s The path of the target file "README.md". Default: "README.md"
|
|
@@ -146,16 +147,18 @@ Options:
|
|
|
146
147
|
|
|
147
148
|
Example:
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
markdown-to-html --title="Hello World!"
|
|
151
|
+
markdown-to-html --config="config/conf.json"
|
|
152
|
+
npx markdown-to-html-cli
|
|
153
|
+
npx markdown-to-html-cli --markdown="Hello World!"
|
|
154
|
+
npx markdown-to-html-cli --no-dark-mode
|
|
155
|
+
npx markdown-to-html-cli --markdown-style-theme dark
|
|
156
|
+
npx markdown-to-html-cli --github-corners https://github.com/jaywcjlove/markdown-to-html-cli
|
|
157
|
+
npx markdown-to-html-cli --github-corners https://github.com/jaywcjlove --github-corners-fork
|
|
158
|
+
npx markdown-to-html-cli --output coverage/index.html
|
|
159
|
+
npx markdown-to-html-cli --source README.md
|
|
160
|
+
npx markdown-to-html-cli --source README.md --style=./style.css
|
|
161
|
+
npx markdown-to-html-cli --source README.md --style='body { color: red; }'
|
|
159
162
|
```
|
|
160
163
|
|
|
161
164
|
## Markdown Features
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,GAAG,EAAE,CAAC"}
|
package/lib/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,QAAqB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,aAAa;AACb,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,QAAqB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAA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AE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC/E;QAED,IAAI,QAAQ,CAAC,MAAM,EAAE;YACnB,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC/F;QAED,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,eAAe,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACvF;QAED,IAAI,QAAQ,CAAC,KAAK,EAAE;YAClB,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SAC3F;QAED,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC;KACpE;IAED,OAAO,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,SAAS,CAAW,CAAC;AACrD,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface RunArgvs extends Omit<ParsedArgs, '_'> {
|
|
|
29
29
|
favicon?: string;
|
|
30
30
|
/** Define the author of a page */
|
|
31
31
|
author?: string;
|
|
32
|
+
/** Override default styles */
|
|
33
|
+
style?: string;
|
|
32
34
|
}
|
|
33
35
|
export interface MDToHTMLOptions extends RunArgvs {
|
|
34
36
|
/** [rehype-document](https://github.com/rehypejs/rehype-document#options) options */
|
package/lib/index.js
CHANGED
|
@@ -38,6 +38,18 @@ export function run(opts = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
const options = formatConfig({ ...opts, ...argvs });
|
|
40
40
|
const output = path.resolve(argvs.output);
|
|
41
|
+
if (!Array.isArray(options.document.style))
|
|
42
|
+
options.document.style = [options.document.style].flat().filter(Boolean);
|
|
43
|
+
if (options.style) {
|
|
44
|
+
const stylePath = path.resolve(process.cwd(), options.style);
|
|
45
|
+
if (fs.existsSync(stylePath)) {
|
|
46
|
+
const cssString = fs.readFileSync(stylePath).toString();
|
|
47
|
+
options.document.style.push(cssString);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
options.document.style.push(options.style);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
const strMarkdown = create({ ...argvs, ...options });
|
|
42
54
|
fs.writeFileSync(output, strMarkdown);
|
|
43
55
|
console.log(`\nmarkdown-to-html: \x1b[32;1m${path.relative(process.cwd(), output)}\x1b[0m\n`);
|
|
@@ -54,6 +66,7 @@ export const cliHelp = `\n Usage: markdown-to-html [options] [--help|h]
|
|
|
54
66
|
--keywords Define keywords for search engines.
|
|
55
67
|
--no-dark-mode Disable light and dark theme styles button.
|
|
56
68
|
--markdown Markdown string.
|
|
69
|
+
--style Override default styles. css file path or css string.
|
|
57
70
|
--markdown-style-theme Setting markdown-style light/dark theme.
|
|
58
71
|
--output, -o Output static pages to the specified directory. Default: "index.html"
|
|
59
72
|
--source, -s The path of the target file "README.md". Default: "README.md"
|
|
@@ -73,6 +86,8 @@ export const exampleHelp = `\n Example:
|
|
|
73
86
|
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--github-corners\x1b[0m https://github.com/jaywcjlove --github-corners-fork
|
|
74
87
|
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--output\x1b[0m coverage/index.html
|
|
75
88
|
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md
|
|
89
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md --style=./style.css
|
|
90
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md --style='body { color: red; }'
|
|
76
91
|
|
|
77
92
|
`;
|
|
78
93
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAwB,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAwB,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAyCxB,MAAM,UAAU,GAAG,CAAC,OAAO,EAAyB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAW,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACtD,KAAK,EAAE;YACL,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,GAAG;YACZ,MAAM,EAAE,GAAG;YACX,MAAM,EAAE,GAAG;YACX,MAAM,EAAE,GAAG;SACZ;QACD,OAAO,EAAE;YACP,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK;YACxC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK;YAClC,MAAM,EAA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
|
|
4
4
|
cursor: pointer;
|
|
@@ -11,31 +11,31 @@ const style = `.markdown-body pre .copied {
|
|
|
11
11
|
font-size: 12px;
|
|
12
12
|
transition: all .3s;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
markdown-style pre .copied:not(.active) {
|
|
15
15
|
visibility: hidden;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
markdown-style pre:hover .copied {
|
|
18
18
|
visibility: visible;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
markdown-style pre:hover .copied:hover {
|
|
21
21
|
background: #4caf50;
|
|
22
22
|
color: #fff;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
markdown-style pre:hover .copied:active,
|
|
25
|
+
markdown-style pre .copied.active {
|
|
26
26
|
background: #2e9b33;
|
|
27
27
|
color: #fff;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
markdown-style pre .copied .octicon-copy {
|
|
30
30
|
display: block;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
markdown-style pre .copied .octicon-check {
|
|
33
33
|
display: none;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
markdown-style pre .active .octicon-copy {
|
|
36
36
|
display: none;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
markdown-style pre .active .octicon-check {
|
|
39
39
|
display: block;
|
|
40
40
|
}`;
|
|
41
41
|
export function copyStyle() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-to-html-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Command line tool generates markdown as html.",
|
|
6
6
|
"homepage": "https://jaywcjlove.github.io/markdown-to-html-cli",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"fs-extra": "~10.1.0",
|
|
46
46
|
"minimist": "~1.2.5",
|
|
47
47
|
"rehype-autolink-headings": "~6.1.0",
|
|
48
|
-
"rehype-document": "~6.0
|
|
48
|
+
"rehype-document": "~6.1.0",
|
|
49
49
|
"rehype-format": "~4.0.1",
|
|
50
|
-
"rehype-prism-plus": "1.
|
|
50
|
+
"rehype-prism-plus": "1.5.0",
|
|
51
51
|
"rehype-slug": "~5.0.0",
|
|
52
52
|
"rehype-urls": "~1.1.1",
|
|
53
53
|
"remark-gemoji": "~7.0.1"
|
package/src/cli.ts
CHANGED
package/src/create.ts
CHANGED
|
@@ -7,13 +7,13 @@ import remarkGemoji from 'remark-gemoji';
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import rehypeUrls from 'rehype-urls';
|
|
9
9
|
import rehypeFormat from 'rehype-format';
|
|
10
|
-
import { githubCorners } from './nodes/github-corners
|
|
11
|
-
import { githubCornersFork } from './nodes/github-corners-fork
|
|
12
|
-
import { octiconLink } from './nodes/octiconLink
|
|
13
|
-
import { markdownStyle } from './nodes/markdown-style
|
|
14
|
-
import { copyElement, copyStyle, copyScript } from './nodes/copy
|
|
15
|
-
import { darkMode } from './nodes/dark-mode
|
|
16
|
-
import { MDToHTMLOptions } from './index
|
|
10
|
+
import { githubCorners } from './nodes/github-corners';
|
|
11
|
+
import { githubCornersFork } from './nodes/github-corners-fork';
|
|
12
|
+
import { octiconLink } from './nodes/octiconLink';
|
|
13
|
+
import { markdownStyle } from './nodes/markdown-style';
|
|
14
|
+
import { copyElement, copyStyle, copyScript } from './nodes/copy';
|
|
15
|
+
import { darkMode } from './nodes/dark-mode';
|
|
16
|
+
import { MDToHTMLOptions } from './index';
|
|
17
17
|
|
|
18
18
|
// https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-when-using-the-experimental-modules-flag
|
|
19
19
|
// export const _dirname = dirname(fileURLToPath(import.meta.url));
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,11 @@ import path from 'path';
|
|
|
3
3
|
import minimist, { ParsedArgs } from 'minimist';
|
|
4
4
|
import { Options } from 'rehype-document';
|
|
5
5
|
import { RehypeRewriteOptions } from 'rehype-rewrite';
|
|
6
|
-
import { create } from './create
|
|
7
|
-
import { formatConfig } from './utils
|
|
6
|
+
import { create } from './create';
|
|
7
|
+
import { formatConfig } from './utils';
|
|
8
8
|
|
|
9
|
-
export * from './create
|
|
10
|
-
export * from './utils
|
|
9
|
+
export * from './create';
|
|
10
|
+
export * from './utils';
|
|
11
11
|
|
|
12
12
|
export interface RunArgvs extends Omit<ParsedArgs, '_'> {
|
|
13
13
|
version?: string;
|
|
@@ -35,6 +35,8 @@ export interface RunArgvs extends Omit<ParsedArgs, '_'> {
|
|
|
35
35
|
favicon?: string;
|
|
36
36
|
/** Define the author of a page */
|
|
37
37
|
author?: string;
|
|
38
|
+
/** Override default styles */
|
|
39
|
+
style?: string;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export interface MDToHTMLOptions extends RunArgvs {
|
|
@@ -81,6 +83,18 @@ export function run(opts = {} as Omit<RunArgvs, '_'>) {
|
|
|
81
83
|
const options = formatConfig({ ...opts, ...argvs });
|
|
82
84
|
const output = path.resolve(argvs.output);
|
|
83
85
|
|
|
86
|
+
|
|
87
|
+
if (!Array.isArray(options.document.style)) options.document.style = [options.document.style].flat().filter(Boolean);
|
|
88
|
+
if (options.style) {
|
|
89
|
+
const stylePath = path.resolve(process.cwd(), options.style);
|
|
90
|
+
if (fs.existsSync(stylePath)) {
|
|
91
|
+
const cssString = fs.readFileSync(stylePath).toString();
|
|
92
|
+
options.document.style.push(cssString);
|
|
93
|
+
} else {
|
|
94
|
+
options.document.style.push(options.style);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
84
98
|
const strMarkdown = create({ ...argvs, ...options });
|
|
85
99
|
fs.writeFileSync(output, strMarkdown);
|
|
86
100
|
console.log(`\nmarkdown-to-html: \x1b[32;1m${path.relative(process.cwd(), output)}\x1b[0m\n`);
|
|
@@ -98,6 +112,7 @@ export const cliHelp: string = `\n Usage: markdown-to-html [options] [--help|h]
|
|
|
98
112
|
--keywords Define keywords for search engines.
|
|
99
113
|
--no-dark-mode Disable light and dark theme styles button.
|
|
100
114
|
--markdown Markdown string.
|
|
115
|
+
--style Override default styles. css file path or css string.
|
|
101
116
|
--markdown-style-theme Setting markdown-style light/dark theme.
|
|
102
117
|
--output, -o Output static pages to the specified directory. Default: "index.html"
|
|
103
118
|
--source, -s The path of the target file "README.md". Default: "README.md"
|
|
@@ -118,5 +133,7 @@ export const exampleHelp: string =`\n Example:
|
|
|
118
133
|
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--github-corners\x1b[0m https://github.com/jaywcjlove --github-corners-fork
|
|
119
134
|
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--output\x1b[0m coverage/index.html
|
|
120
135
|
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md
|
|
136
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md --style=./style.css
|
|
137
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md --style='body { color: red; }'
|
|
121
138
|
|
|
122
139
|
`;
|
package/src/nodes/copy.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Element } from 'hast';
|
|
2
2
|
|
|
3
|
-
const style =
|
|
3
|
+
const style = `markdown-style pre .copied {
|
|
4
4
|
display: flex;
|
|
5
5
|
position: absolute;
|
|
6
6
|
cursor: pointer;
|
|
@@ -13,31 +13,31 @@ const style = `.markdown-body pre .copied {
|
|
|
13
13
|
font-size: 12px;
|
|
14
14
|
transition: all .3s;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
markdown-style pre .copied:not(.active) {
|
|
17
17
|
visibility: hidden;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
markdown-style pre:hover .copied {
|
|
20
20
|
visibility: visible;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
markdown-style pre:hover .copied:hover {
|
|
23
23
|
background: #4caf50;
|
|
24
24
|
color: #fff;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
markdown-style pre:hover .copied:active,
|
|
27
|
+
markdown-style pre .copied.active {
|
|
28
28
|
background: #2e9b33;
|
|
29
29
|
color: #fff;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
markdown-style pre .copied .octicon-copy {
|
|
32
32
|
display: block;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
markdown-style pre .copied .octicon-check {
|
|
35
35
|
display: none;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
markdown-style pre .active .octicon-copy {
|
|
38
38
|
display: none;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
markdown-style pre .active .octicon-check {
|
|
41
41
|
display: block;
|
|
42
42
|
}`;
|
|
43
43
|
|