markdown-to-html-cli 3.4.18 → 3.5.1

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 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
- npm markdown-to-html-cli
150
- npm markdown-to-html --title="Hello World!"
151
- npm markdown-to-html --config="config/conf.json"
152
- npm markdown-to-html-cli --markdown="Hello World!"
153
- npm markdown-to-html-cli --no-dark-mode
154
- npm markdown-to-html-cli --markdown-style-theme dark
155
- npm markdown-to-html-cli --github-corners https://github.com/jaywcjlove/markdown-to-html-cli
156
- npm markdown-to-html-cli --github-corners https://github.com/jaywcjlove --github-corners-fork
157
- npm markdown-to-html-cli --output coverage/index.html
158
- npm markdown-to-html-cli --source README.md
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/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,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAuCxB,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,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,WAAW;YAC5C,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;YACnC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,YAAY;SAC9C;KACF,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,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K,CAAC,CAAC;QAC7D,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC5B,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;YACxD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACxC;aAAM;YACL,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC5C;KACF;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;AAChG,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAW;;;;;;;;;;;;;;;;;;;CAmB9B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAU;;;;;;;;;;;;;;;CAejC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-to-html-cli",
3
- "version": "3.4.18",
3
+ "version": "3.5.1",
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",
@@ -41,7 +41,7 @@
41
41
  "@types/minimist": "~1.2.2",
42
42
  "@uiw/github-corners": "~1.5.14",
43
43
  "@wcj/markdown-style": "~1.0.9",
44
- "@wcj/markdown-to-html": "~2.0.3",
44
+ "@wcj/markdown-to-html": "~2.1.0",
45
45
  "fs-extra": "~10.1.0",
46
46
  "minimist": "~1.2.5",
47
47
  "rehype-autolink-headings": "~6.1.0",
package/src/index.ts CHANGED
@@ -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
  `;