markdown-to-html-cli 3.2.12 → 3.3.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 +1 -9
- package/lib/create.js +56 -92
- package/lib/create.js.map +1 -1
- package/lib/index.d.ts +3 -9
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/nodes/copy.d.ts +2 -0
- package/lib/nodes/copy.js +76 -1
- package/lib/nodes/copy.js.map +1 -1
- package/lib/nodes/dark-mode.d.ts +6 -0
- package/lib/nodes/dark-mode.js +29 -0
- package/lib/nodes/dark-mode.js.map +1 -0
- package/lib/nodes/{githubCornersFork.d.ts → github-corners-fork.d.ts} +0 -0
- package/lib/nodes/github-corners-fork.js +122 -0
- package/lib/nodes/github-corners-fork.js.map +1 -0
- package/lib/nodes/{githubCorners.d.ts → github-corners.d.ts} +1 -1
- package/lib/nodes/github-corners.js +110 -0
- package/lib/nodes/github-corners.js.map +1 -0
- package/lib/nodes/markdown-style.d.ts +2 -0
- package/lib/nodes/markdown-style.js +107 -0
- package/lib/nodes/markdown-style.js.map +1 -0
- package/package.json +7 -16
- package/src/cli.ts +5 -0
- package/src/create.ts +103 -0
- package/src/index.ts +118 -0
- package/src/nodes/copy.ts +148 -0
- package/src/nodes/dark-mode.ts +31 -0
- package/{github-fork-ribbon.css → src/nodes/github-corners-fork.ts} +38 -1
- package/src/nodes/github-corners.ts +116 -0
- package/src/nodes/markdown-style.ts +109 -0
- package/src/nodes/octiconLink.ts +12 -0
- package/src/utils.ts +50 -0
- package/github.css +0 -930
- package/lib/nodes/githubCorners.js +0 -59
- package/lib/nodes/githubCorners.js.map +0 -1
- package/lib/nodes/githubCornersFork.js +0 -20
- package/lib/nodes/githubCornersFork.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @uiw/github-corners@1.5.10
|
|
3
|
+
* https://github.com/uiwjs/react-github-corners
|
|
4
|
+
*/
|
|
5
|
+
const scriptString = `const TEMPLATE = document.createElement("template");
|
|
6
|
+
TEMPLATE.innerHTML = \`
|
|
7
|
+
<style>
|
|
8
|
+
:host a:hover .octo-arm {
|
|
9
|
+
animation: octocat-wave 560ms ease-in-out;
|
|
10
|
+
}
|
|
11
|
+
@keyframes octocat-wave {
|
|
12
|
+
0%, 100% {
|
|
13
|
+
transform: rotate(0);
|
|
14
|
+
}
|
|
15
|
+
20%, 60% {
|
|
16
|
+
transform: rotate(-25deg);
|
|
17
|
+
}
|
|
18
|
+
40%, 80% {
|
|
19
|
+
transform: rotate(10deg);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
@media (max-width:500px) {
|
|
23
|
+
:host a:hover .octo-arm {
|
|
24
|
+
animation: none;
|
|
25
|
+
}
|
|
26
|
+
:host .octo-arm {
|
|
27
|
+
animation: octocat-wave 560ms ease-in-out;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
<svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true" style="position: absolute; border: 0px; top: 0px;">
|
|
32
|
+
<a xlink:href="https://github.com/uiwjs/react-github-corners" target="_blank" rel="nofollow sponsored" style="fill: rgb(21, 21, 19); color: rgb(255, 255, 255);">
|
|
33
|
+
<g>
|
|
34
|
+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
|
|
35
|
+
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" class="octo-arm" style="transform-origin: 130px 106px;"></path>
|
|
36
|
+
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
|
|
37
|
+
</g>
|
|
38
|
+
</a>
|
|
39
|
+
</svg>
|
|
40
|
+
\`;
|
|
41
|
+
export class GithubCorners extends HTMLElement {
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
this.right = '0';
|
|
45
|
+
this.shadow = this.attachShadow({ mode: 'open' });
|
|
46
|
+
this.shadow.appendChild(this.ownerDocument.importNode(TEMPLATE.content, true));
|
|
47
|
+
this.update();
|
|
48
|
+
}
|
|
49
|
+
static get observedAttributes() {
|
|
50
|
+
return ['z-index', 'target', 'height', 'width', 'href', 'color', 'fill', 'position', 'top', 'left', 'right', 'bottom', 'transform'];
|
|
51
|
+
}
|
|
52
|
+
setAttr(name, value) {
|
|
53
|
+
const svg = this.shadow.querySelector('svg');
|
|
54
|
+
if (/(href)/.test(name.toLocaleLowerCase())) {
|
|
55
|
+
svg.lastElementChild.setAttribute('xlink:href', value);
|
|
56
|
+
}
|
|
57
|
+
else if (/(color|fill)/.test(name.toLocaleLowerCase())) {
|
|
58
|
+
svg.firstElementChild.style[name] = value;
|
|
59
|
+
}
|
|
60
|
+
else if (/(z-index|height|width|position|top|left|right|bottom|transform)/.test(name.toLocaleLowerCase())) {
|
|
61
|
+
svg.style[name] = value;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
svg.setAttribute(name, value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
update() {
|
|
68
|
+
;
|
|
69
|
+
[...this.getAttributeNames(), 'right'].forEach((name) => {
|
|
70
|
+
const value = this.getAttribute(name) || this[name] || '';
|
|
71
|
+
this.setAttr(name, value);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
75
|
+
if (oldValue !== newValue) {
|
|
76
|
+
this.setAttr(name, newValue);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
customElements.define('github-corners', GithubCorners);`;
|
|
81
|
+
export function githubCorners(opts) {
|
|
82
|
+
const { href } = opts;
|
|
83
|
+
if (!href) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
type: 'element',
|
|
89
|
+
tagName: 'github-corners',
|
|
90
|
+
properties: {
|
|
91
|
+
target: '__blank',
|
|
92
|
+
position: 'fixed',
|
|
93
|
+
href,
|
|
94
|
+
},
|
|
95
|
+
children: []
|
|
96
|
+
}, {
|
|
97
|
+
type: 'element',
|
|
98
|
+
tagName: 'script',
|
|
99
|
+
properties: {
|
|
100
|
+
type: 'module',
|
|
101
|
+
// src: 'https://unpkg.com/@uiw/github-corners?module',
|
|
102
|
+
},
|
|
103
|
+
children: [{
|
|
104
|
+
type: 'text',
|
|
105
|
+
value: scriptString,
|
|
106
|
+
}]
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=github-corners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-corners.js","sourceRoot":"","sources":["../../src/nodes/github-corners.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDA2EmC,CAAC;AAEzD,MAAM,UAAU,aAAa,CAAC,IAAmB;IAC/C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,IAAI,EAAE;QACT,OAAO;KACR;IACD,OAAO;QACL;YACE,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,gBAAgB;YACzB,UAAU,EAAE;gBACV,MAAM,EAAE,SAAS;gBACjB,QAAQ,EAAE,OAAO;gBACjB,IAAI;aACL;YACD,QAAQ,EAAE,EAAE;SACb,EAAE;YACD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,QAAQ;YACjB,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,uDAAuD;aACxD;YACD,QAAQ,EAAE,CAAC;oBACT,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,YAAY;iBACpB,CAAC;SACH;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wcj/markdown-to-html@2.0.1
|
|
3
|
+
* https://github.com/jaywcjlove/markdown-to-html
|
|
4
|
+
*/
|
|
5
|
+
const scriptString = `
|
|
6
|
+
const __TEMPLATE__ = document.createElement('template');
|
|
7
|
+
__TEMPLATE__.innerHTML = \`
|
|
8
|
+
<style>
|
|
9
|
+
:host [data-color-mode*='light'] { --color-prettylights-syntax-comment: #6e7781; --color-prettylights-syntax-constant: #0550ae; --color-prettylights-syntax-entity: #8250df; --color-prettylights-syntax-storage-modifier-import: #24292f; --color-prettylights-syntax-entity-tag: #116329; --color-prettylights-syntax-keyword: #cf222e; --color-prettylights-syntax-string: #0a3069; --color-prettylights-syntax-variable: #953800; --color-prettylights-syntax-brackethighlighter-unmatched: #82071e; --color-prettylights-syntax-invalid-illegal-text: #f6f8fa; --color-prettylights-syntax-invalid-illegal-bg: #82071e; --color-prettylights-syntax-carriage-return-text: #f6f8fa; --color-prettylights-syntax-carriage-return-bg: #cf222e; --color-prettylights-syntax-string-regexp: #116329; --color-prettylights-syntax-markup-list: #3b2300; --color-prettylights-syntax-markup-heading: #0550ae; --color-prettylights-syntax-markup-italic: #24292f; --color-prettylights-syntax-markup-bold: #24292f; --color-prettylights-syntax-markup-deleted-text: #82071e; --color-prettylights-syntax-markup-deleted-bg: #FFEBE9; --color-prettylights-syntax-markup-inserted-text: #116329; --color-prettylights-syntax-markup-inserted-bg: #dafbe1; --color-prettylights-syntax-markup-changed-text: #953800; --color-prettylights-syntax-markup-changed-bg: #ffd8b5; --color-prettylights-syntax-markup-ignored-text: #eaeef2; --color-prettylights-syntax-markup-ignored-bg: #0550ae; --color-prettylights-syntax-meta-diff-range: #8250df; --color-prettylights-syntax-brackethighlighter-angle: #57606a; --color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f; --color-prettylights-syntax-constant-other-reference-link: #0a3069; --color-fg-default: #24292f; --color-fg-muted: #57606a; --color-fg-subtle: #6e7781; --color-canvas-default: #ffffff; --color-canvas-subtle: #f6f8fa; --color-border-default: #d0d7de; --color-border-muted: hsla(210,18%,87%,1); --color-neutral-muted: rgba(175,184,193,0.2); --color-accent-fg: #0969da; --color-accent-emphasis: #0969da; --color-attention-subtle: #fff8c5; --color-danger-fg: #cf222e; } :host [data-color-mode*='dark'] { --color-prettylights-syntax-comment: #8b949e; --color-prettylights-syntax-constant: #79c0ff; --color-prettylights-syntax-entity: #d2a8ff; --color-prettylights-syntax-storage-modifier-import: #c9d1d9; --color-prettylights-syntax-entity-tag: #7ee787; --color-prettylights-syntax-keyword: #ff7b72; --color-prettylights-syntax-string: #a5d6ff; --color-prettylights-syntax-variable: #ffa657; --color-prettylights-syntax-brackethighlighter-unmatched: #f85149; --color-prettylights-syntax-invalid-illegal-text: #f0f6fc; --color-prettylights-syntax-invalid-illegal-bg: #8e1519; --color-prettylights-syntax-carriage-return-text: #f0f6fc; --color-prettylights-syntax-carriage-return-bg: #b62324; --color-prettylights-syntax-string-regexp: #7ee787; --color-prettylights-syntax-markup-list: #f2cc60; --color-prettylights-syntax-markup-heading: #1f6feb; --color-prettylights-syntax-markup-italic: #c9d1d9; --color-prettylights-syntax-markup-bold: #c9d1d9; --color-prettylights-syntax-markup-deleted-text: #ffdcd7; --color-prettylights-syntax-markup-deleted-bg: #67060c; --color-prettylights-syntax-markup-inserted-text: #aff5b4; --color-prettylights-syntax-markup-inserted-bg: #033a16; --color-prettylights-syntax-markup-changed-text: #ffdfb6; --color-prettylights-syntax-markup-changed-bg: #5a1e02; --color-prettylights-syntax-markup-ignored-text: #c9d1d9; --color-prettylights-syntax-markup-ignored-bg: #1158c7; --color-prettylights-syntax-meta-diff-range: #d2a8ff; --color-prettylights-syntax-brackethighlighter-angle: #8b949e; --color-prettylights-syntax-sublimelinter-gutter-mark: #484f58; --color-prettylights-syntax-constant-other-reference-link: #a5d6ff; --color-fg-default: #c9d1d9; --color-fg-muted: #8b949e; --color-fg-subtle: #484f58; --color-canvas-default: #0d1117; --color-canvas-subtle: #161b22; --color-border-default: #30363d; --color-border-muted: #21262d; --color-neutral-muted: rgba(110,118,129,0.4); --color-accent-fg: #58a6ff; --color-accent-emphasis: #1f6feb; --color-attention-subtle: rgba(187,128,9,0.15); --color-danger-fg: #f85149; } .markdown-body { -webkit-text-size-adjust: 100%; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; font-size: 16px; line-height: 1.5; word-wrap: break-word; color: var(--color-fg-default); background-color: var(--color-canvas-default); } :host details, :host figcaption, :host figure { display: block; } :host summary { display: list-item; } :host [hidden] { display: none !important; } :host a { background-color: transparent; color: var(--color-accent-fg); text-decoration: none; } :host a:active, :host a:hover { outline-width: 0; } :host abbr[title] { border-bottom: none; text-decoration: underline dotted; } :host b, :host strong { font-weight: 600; } :host dfn { font-style: italic; } :host h1 { margin: .67em 0; font-weight: 600; padding-bottom: .3em; font-size: 2em; border-bottom: 1px solid var(--color-border-muted); } :host mark { background-color: var(--color-attention-subtle); color: var(--color-text-primary); } :host small { font-size: 90%; } :host sub, :host sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } :host sub { bottom: -0.25em; } :host sup { top: -0.5em; } :host img { border-style: none; max-width: 100%; box-sizing: content-box; background-color: var(--color-canvas-default); } :host code, :host kbd, :host pre, :host samp { font-family: monospace,monospace; font-size: 1em; } :host figure { margin: 1em 40px; } :host hr { box-sizing: content-box; overflow: hidden; background: transparent; border-bottom: 1px solid var(--color-border-muted); height: .25em; padding: 0; margin: 24px 0; background-color: var(--color-border-default); border: 0; } :host input { font: inherit; margin: 0; overflow: visible; font-family: inherit; font-size: inherit; line-height: inherit; } :host [type=button], :host [type=reset], :host [type=submit] { -webkit-appearance: button; } :host [type=button]::-moz-focus-inner, :host [type=reset]::-moz-focus-inner, :host [type=submit]::-moz-focus-inner { border-style: none; padding: 0; } :host [type=button]:-moz-focusring, :host [type=reset]:-moz-focusring, :host [type=submit]:-moz-focusring { outline: 1px dotted ButtonText; } :host [type=checkbox], :host [type=radio] { box-sizing: border-box; padding: 0; } :host [type=number]::-webkit-inner-spin-button, :host [type=number]::-webkit-outer-spin-button { height: auto; } :host [type=search] { -webkit-appearance: textfield; outline-offset: -2px; } :host [type=search]::-webkit-search-cancel-button, :host [type=search]::-webkit-search-decoration { -webkit-appearance: none; } :host ::-webkit-input-placeholder { color: inherit; opacity: .54; } :host ::-webkit-file-upload-button { -webkit-appearance: button; font: inherit; } :host a:hover { text-decoration: underline; } :host hr::before { display: table; content: ""; } :host hr::after { display: table; clear: both; content: ""; } :host table { border-spacing: 0; border-collapse: collapse; display: block; width: max-content; max-width: 100%; overflow: auto; } :host td, :host th { padding: 0; } :host details summary { cursor: pointer; } :host details:not([open])>*:not(summary) { display: none !important; } :host kbd { display: inline-block; padding: 3px 5px; font: 11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; line-height: 10px; color: var(--color-fg-default); vertical-align: middle; background-color: var(--color-canvas-subtle); border: solid 1px var(--color-neutral-muted); border-bottom-color: var(--color-neutral-muted); border-radius: 6px; box-shadow: inset 0 -1px 0 var(--color-neutral-muted); } :host h1, :host h2, :host h3, :host h4, :host h5, :host h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25; } :host h2 { font-weight: 600; padding-bottom: .3em; font-size: 1.5em; border-bottom: 1px solid var(--color-border-muted); } :host h3 { font-weight: 600; font-size: 1.25em; } :host h4 { font-weight: 600; font-size: 1em; } :host h5 { font-weight: 600; font-size: .875em; } :host h6 { font-weight: 600; font-size: .85em; color: var(--color-fg-muted); } :host p { margin-top: 0; margin-bottom: 10px; } :host blockquote { margin: 0; padding: 0 1em; color: var(--color-fg-muted); border-left: .25em solid var(--color-border-default); } :host ul, :host ol { margin-top: 0; margin-bottom: 0; padding-left: 2em; } :host ol ol, :host ul ol { list-style-type: lower-roman; } :host ul ul ol, :host ul ol ol, :host ol ul ol, :host ol ol ol { list-style-type: lower-alpha; } :host dd { margin-left: 0; } :host tt, :host code { font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; font-size: 12px; } :host pre { margin-top: 0; margin-bottom: 0; font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; font-size: 12px; word-wrap: normal; } :host .octicon { display: inline-block; overflow: visible !important; vertical-align: text-bottom; fill: currentColor; }
|
|
10
|
+
:host ::placeholder { color: var(--color-fg-subtle); opacity: 1; } :host input::-webkit-outer-spin-button, :host input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; appearance: none; } .token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--color-prettylights-syntax-comment); } .token.namespace { opacity: 0.7; } .token.tag, .token.selector, .token.constant, .token.symbol, .token.deleted { color: var(--color-prettylights-syntax-entity-tag); } .token.maybe-class-name { color: var(--color-prettylights-syntax-variable); } .token.property-access, .token.operator, .token.boolean, .token.number, .token.selector .token.class, .token.attr-name, .token.string, .token.char, .token.builtin { color: var(--color-prettylights-syntax-constant); } .token.deleted { color: var(--color-prettylights-syntax-markup-deleted-text); } .token.property { color: var(--color-prettylights-syntax-constant); } .token.punctuation { color: var(--color-prettylights-syntax-markup-bold); } .token.function { color: var(--color-prettylights-syntax-entity); } .code-line .token.deleted { background-color: var(--color-prettylights-syntax-markup-deleted-bg); } .token.inserted { color: var(--color-prettylights-syntax-markup-inserted-text); } .code-line .token.inserted { background-color: var(--color-prettylights-syntax-markup-inserted-bg); } .token.variable { color: var(--color-prettylights-syntax-constant); } .token.entity, .token.url, .language-css .token.string, .style .token.string { color: var(--color-prettylights-syntax-string); } .token.color, .token.atrule, .token.attr-value, .token.function, .token.class-name { color: var(--color-prettylights-syntax-string); } .token.rule, .token.regex, .token.important, .token.keyword { color: var(--color-prettylights-syntax-keyword); } .token.coord { color: var(--color-prettylights-syntax-meta-diff-range); } .token.important, .token.bold { font-weight: bold; } .token.italic { font-style: italic; } .token.entity { cursor: help; } :host [data-catalyst] { display: block; } :host g-emoji { font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; font-size: 1em; font-style: normal !important; font-weight: 400; line-height: 1; vertical-align: -0.075em; } :host g-emoji img { width: 1em; height: 1em; } .markdown-body::before { display: table; content: ""; } .markdown-body::after { display: table; clear: both; content: ""; } .markdown-body>*:first-child { margin-top: 0 !important; } .markdown-body>*:last-child { margin-bottom: 0 !important; } :host a:not([href]) { color: inherit; text-decoration: none; } :host .absent { color: var(--color-danger-fg); } :host .anchor { float: left; padding-right: 4px; margin-left: -20px; line-height: 1; } :host .anchor:focus { outline: none; } :host p, :host blockquote, :host ul, :host ol, :host dl, :host table, :host pre, :host details { margin-top: 0; margin-bottom: 16px; } :host blockquote>:first-child { margin-top: 0; } :host blockquote>:last-child { margin-bottom: 0; } :host sup>a::before { content: "["; } :host sup>a::after { content: "]"; } :host h1 .octicon-link, :host h2 .octicon-link, :host h3 .octicon-link, :host h4 .octicon-link, :host h5 .octicon-link, :host h6 .octicon-link { color: var(--color-fg-default); vertical-align: middle; visibility: hidden; } :host h1:hover .anchor, :host h2:hover .anchor, :host h3:hover .anchor, :host h4:hover .anchor, :host h5:hover .anchor, :host h6:hover .anchor { text-decoration: none; } :host h1:hover .anchor .octicon-link, :host h2:hover .anchor .octicon-link, :host h3:hover .anchor .octicon-link, :host h4:hover .anchor .octicon-link, :host h5:hover .anchor .octicon-link, :host h6:hover .anchor .octicon-link { visibility: visible; } :host h1 tt, :host h1 code, :host h2 tt, :host h2 code, :host h3 tt, :host h3 code, :host h4 tt, :host h4 code, :host h5 tt, :host h5 code, :host h6 tt, :host h6 code { padding: 0 .2em; font-size: inherit; } :host ul.no-list, :host ol.no-list { padding: 0; list-style-type: none; } :host ol[type="1"] { list-style-type: decimal; } :host ol[type=a] { list-style-type: lower-alpha; } :host ol[type=i] { list-style-type: lower-roman; } :host div>ol:not([type]) { list-style-type: decimal; } :host ul ul, :host ul ol, :host ol ol, :host ol ul { margin-top: 0; margin-bottom: 0; } :host li>p { margin-top: 16px; } :host li+li { margin-top: .25em; } :host dl { padding: 0; } :host dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: 600; } :host dl dd { padding: 0 16px; margin-bottom: 16px; } :host table th { font-weight: 600; } :host table th, :host table td { padding: 6px 13px; border: 1px solid var(--color-border-default); } :host table tr { background-color: var(--color-canvas-default); border-top: 1px solid var(--color-border-muted); } :host table tr:nth-child(2n) { background-color: var(--color-canvas-subtle); } :host table img { background-color: transparent; } :host img[align=right] { padding-left: 20px; } :host img[align=left] { padding-right: 20px; } :host .emoji { max-width: none; vertical-align: text-top; background-color: transparent; } :host span.frame { display: block; overflow: hidden; } :host span.frame>span { display: block; float: left; width: auto; padding: 7px; margin: 13px 0 0; overflow: hidden; border: 1px solid var(--color-border-default); } :host span.frame span img { display: block; float: left; } :host span.frame span span { display: block; padding: 5px 0 0; clear: both; color: var(--color-fg-default); } :host span.align-center { display: block; overflow: hidden; clear: both; } :host span.align-center>span { display: block; margin: 13px auto 0; overflow: hidden; text-align: center; } :host span.align-center span img { margin: 0 auto; text-align: center; } :host span.align-right { display: block; overflow: hidden; clear: both; } :host span.align-right>span { display: block; margin: 13px 0 0; overflow: hidden; text-align: right; } :host span.align-right span img { margin: 0; text-align: right; } :host span.float-left { display: block; float: left; margin-right: 13px; overflow: hidden; } :host span.float-left span { margin: 13px 0 0; } :host span.float-right { display: block; float: right; margin-left: 13px; overflow: hidden; } :host span.float-right>span { display: block; margin: 13px auto 0; overflow: hidden; text-align: right; } :host code, :host tt { padding: .2em .4em; margin: 0; font-size: 85%; background-color: var(--color-neutral-muted); border-radius: 6px; } :host code br, :host tt br { display: none; } :host del code { text-decoration: inherit; } :host pre code { font-size: 100%; } :host pre>code { padding: 0; margin: 0; word-break: normal; white-space: pre; background: transparent; border: 0; } :host .highlight { margin-bottom: 16px; } :host .highlight pre { margin-bottom: 0; word-break: normal; } :host .highlight pre, :host pre { position: relative; padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: var(--color-canvas-subtle); border-radius: 6px; } :host pre code, :host pre tt { display: inline; max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } :host .csv-data td, :host .csv-data th { padding: 5px; overflow: hidden; font-size: 12px; line-height: 1; text-align: left; white-space: nowrap; } :host .csv-data .blob-num { padding: 10px 8px 9px; text-align: right; background: var(--color-canvas-default); border: 0; } :host .csv-data tr { border-top: 0; } :host .csv-data th { font-weight: 600; background: var(--color-canvas-subtle); border-top: 0; } :host .footnotes { font-size: 12px; color: var(--color-fg-muted); border-top: 1px solid var(--color-border-default); } :host .footnotes ol { padding-left: 16px; } :host .footnotes li { position: relative; } :host .footnotes li:target::before { position: absolute; top: -8px; right: -8px; bottom: -8px; left: -24px; pointer-events: none; content: ""; border: 2px solid var(--color-accent-emphasis); border-radius: 6px; } :host .footnotes li:target { color: var(--color-fg-default); } :host .footnotes .data-footnote-backref g-emoji { font-family: monospace; } :host .task-list-item { list-style-type: none; } :host .task-list-item label { font-weight: 400; } :host .task-list-item.enabled label { cursor: pointer; } :host .task-list-item+.task-list-item { margin-top: 3px; } :host .task-list-item .handle { display: none; } :host .task-list-item-checkbox, :host input[type="checkbox"] { margin: 0 .2em .25em -1.6em; vertical-align: middle; } :host .contains-task-list:dir(rtl) .task-list-item-checkbox, :host .contains-task-list:dir(rtl) input[type="checkbox"] { margin: 0 -1.6em .25em .2em; } :host ::-webkit-calendar-picker-indicator { filter: invert(50%); }
|
|
11
|
+
</style>
|
|
12
|
+
\`;
|
|
13
|
+
// See https://html.spec.whatwg.org/multipage/common-dom-interfaces.html
|
|
14
|
+
// #reflecting-content-attributes-in-idl-attributes.
|
|
15
|
+
const installStringReflection = (obj, attrName, propName = attrName) => {
|
|
16
|
+
Object.defineProperty(obj, propName, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get() {
|
|
19
|
+
const value = this.getAttribute(attrName);
|
|
20
|
+
return value === null ? '' : value;
|
|
21
|
+
},
|
|
22
|
+
set(v) {
|
|
23
|
+
this.setAttribute(attrName, v);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export class MarkdownStyle extends HTMLElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.initTheme = this.getAttribute('theme');
|
|
31
|
+
installStringReflection(this, 'theme');
|
|
32
|
+
this.shadow = this.attachShadow({ mode: 'open' });
|
|
33
|
+
this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true));
|
|
34
|
+
this.warpper = document.createElement('div');
|
|
35
|
+
this.warpper.classList.add('markdown-body');
|
|
36
|
+
this.shadow.appendChild(this.warpper);
|
|
37
|
+
Array.prototype.slice.call(this.shadow.host.childNodes).forEach((item) => this.warpper.appendChild(item));
|
|
38
|
+
this.setTheme();
|
|
39
|
+
}
|
|
40
|
+
setTheme() {
|
|
41
|
+
if (!this.initTheme) {
|
|
42
|
+
const { colorMode } = document.documentElement.dataset;
|
|
43
|
+
this.theme = colorMode;
|
|
44
|
+
if (this.theme === 'undefined') {
|
|
45
|
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
46
|
+
this.theme = 'dark';
|
|
47
|
+
}
|
|
48
|
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
49
|
+
this.theme = 'light';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.warpper.setAttribute('data-color-mode', this.theme);
|
|
54
|
+
}
|
|
55
|
+
connectedCallback() {
|
|
56
|
+
if (!this.initTheme) {
|
|
57
|
+
this.setTheme();
|
|
58
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
59
|
+
this.theme = document.documentElement.dataset.colorMode;
|
|
60
|
+
this.setTheme();
|
|
61
|
+
});
|
|
62
|
+
// Start observing the target node with the above configuration
|
|
63
|
+
observer.observe(document.documentElement, { attributes: true });
|
|
64
|
+
window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => {
|
|
65
|
+
this.theme = event.matches ? 'light' : 'dark';
|
|
66
|
+
this.setTheme();
|
|
67
|
+
};
|
|
68
|
+
window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => {
|
|
69
|
+
this.theme = event.matches ? 'dark' : 'light';
|
|
70
|
+
this.setTheme();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
customElements.define('markdown-style', MarkdownStyle);
|
|
76
|
+
`;
|
|
77
|
+
export function markdownStyle(child, darkMode) {
|
|
78
|
+
const properties = {};
|
|
79
|
+
if (!darkMode) {
|
|
80
|
+
properties.theme = "light";
|
|
81
|
+
}
|
|
82
|
+
return [{
|
|
83
|
+
type: 'element',
|
|
84
|
+
tagName: 'script',
|
|
85
|
+
properties: {
|
|
86
|
+
type: 'module',
|
|
87
|
+
// src: 'https://unpkg.com/@wcj/markdown-style?module',
|
|
88
|
+
},
|
|
89
|
+
children: [{
|
|
90
|
+
type: 'text',
|
|
91
|
+
value: scriptString
|
|
92
|
+
}]
|
|
93
|
+
}, {
|
|
94
|
+
type: 'element',
|
|
95
|
+
tagName: 'div',
|
|
96
|
+
properties: {
|
|
97
|
+
style: 'max-width: 960px; margin: 28px auto 60px auto; padding: 8px'
|
|
98
|
+
},
|
|
99
|
+
children: [{
|
|
100
|
+
type: 'element',
|
|
101
|
+
properties,
|
|
102
|
+
tagName: 'markdown-style',
|
|
103
|
+
children: child
|
|
104
|
+
}]
|
|
105
|
+
}];
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=markdown-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-style.js","sourceRoot":"","sources":["../../src/nodes/markdown-style.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEpB,CAAA;AAED,MAAM,UAAU,aAAa,CAAC,KAAuB,EAAE,QAAiB;IACtE,MAAM,UAAU,GAA2B,EAAE,CAAA;IAC7C,IAAI,CAAC,QAAQ,EAAE;QACb,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC;KAC5B;IACD,OAAO,CAAC;YACN,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,QAAQ;YACjB,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,uDAAuD;aACxD;YACD,QAAQ,EAAE,CAAC;oBACT,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,YAAY;iBACpB,CAAC;SACH,EAAE;YACD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,6DAA6D;aACrE;YACD,QAAQ,EAAE,CAAC;oBACT,IAAI,EAAE,SAAS;oBACf,UAAU;oBACV,OAAO,EAAE,gBAAgB;oBACzB,QAAQ,EAAE,KAAK;iBAChB,CAAC;SACH,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-to-html-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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",
|
|
@@ -34,31 +34,22 @@
|
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"lib",
|
|
37
|
-
"
|
|
38
|
-
"github.css"
|
|
37
|
+
"src"
|
|
39
38
|
],
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@mapbox/rehype-prism": "~0.8.0",
|
|
42
40
|
"@types/fs-extra": "~9.0.13",
|
|
43
41
|
"@types/minimist": "~1.2.2",
|
|
42
|
+
"@uiw/github-corners": "~1.5.10",
|
|
43
|
+
"@wcj/markdown-style": "~1.0.1",
|
|
44
|
+
"@wcj/markdown-to-html": "~2.0.2",
|
|
44
45
|
"fs-extra": "~10.0.0",
|
|
45
46
|
"minimist": "~1.2.5",
|
|
46
|
-
"rehype-attr": "~2.0.7",
|
|
47
47
|
"rehype-autolink-headings": "~6.1.0",
|
|
48
48
|
"rehype-document": "~6.0.1",
|
|
49
49
|
"rehype-format": "~4.0.1",
|
|
50
|
-
"rehype-
|
|
51
|
-
"rehype-raw": "~6.1.0",
|
|
52
|
-
"rehype-rewrite": "~3.0.4",
|
|
50
|
+
"rehype-prism-plus": "~1.3.2",
|
|
53
51
|
"rehype-slug": "~5.0.0",
|
|
54
|
-
"rehype-stringify": "~9.0.2",
|
|
55
52
|
"rehype-urls": "~1.1.1",
|
|
56
|
-
"
|
|
57
|
-
"rehype-wrap": "~1.0.10",
|
|
58
|
-
"remark-gemoji": "~7.0.1",
|
|
59
|
-
"remark-gfm": "~3.0.1",
|
|
60
|
-
"remark-parse": "~10.0.1",
|
|
61
|
-
"remark-rehype": "~10.1.0",
|
|
62
|
-
"unified": "~10.1.1"
|
|
53
|
+
"remark-gemoji": "~7.0.1"
|
|
63
54
|
}
|
|
64
55
|
}
|
package/src/cli.ts
ADDED
package/src/create.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import markdown, { Options } from '@wcj/markdown-to-html';
|
|
2
|
+
import { getCodeString } from 'rehype-rewrite';
|
|
3
|
+
import rehypeDocument from 'rehype-document';
|
|
4
|
+
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
|
|
5
|
+
import rehypeSlug from 'rehype-slug';
|
|
6
|
+
import remarkGemoji from 'remark-gemoji';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import rehypeUrls from 'rehype-urls';
|
|
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 './';
|
|
17
|
+
|
|
18
|
+
// https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-when-using-the-experimental-modules-flag
|
|
19
|
+
// export const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
// const filename = fileURLToPath(import.meta.url);
|
|
21
|
+
// const dirname = path.dirname(filename);
|
|
22
|
+
|
|
23
|
+
export const _dirname = __dirname;
|
|
24
|
+
export interface CreateOptions extends MDToHTMLOptions { }
|
|
25
|
+
|
|
26
|
+
export function create(options: MDToHTMLOptions = {}) {
|
|
27
|
+
const { markdown: string, document, rewrite, reurls = {}, 'dark-mode': darkModeTheme = true } = options;
|
|
28
|
+
|
|
29
|
+
const mdOptions: Options = {
|
|
30
|
+
hastNode: false,
|
|
31
|
+
remarkPlugins: [remarkGemoji],
|
|
32
|
+
rehypePlugins: [
|
|
33
|
+
[rehypeUrls, (url: any) => {
|
|
34
|
+
if (reurls[url.href]) {
|
|
35
|
+
url.path = reurls[url.href];
|
|
36
|
+
return url.path;
|
|
37
|
+
}
|
|
38
|
+
}],
|
|
39
|
+
[rehypeSlug],
|
|
40
|
+
[rehypeAutolinkHeadings],
|
|
41
|
+
[rehypeFormat],
|
|
42
|
+
],
|
|
43
|
+
rewrite: (node, index, parent) => {
|
|
44
|
+
if ((node.type == 'element' && node.tagName === 'body') || (!document && node.type === 'root')) {
|
|
45
|
+
node.children = markdownStyle(node.children as any, darkModeTheme);
|
|
46
|
+
if (darkModeTheme) {
|
|
47
|
+
darkMode().forEach(item => node.children.unshift(item));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (options['github-corners'] && ((document && node.type == 'element' && node.tagName === 'body') || (!document && node.type === 'root'))) {
|
|
51
|
+
node.children = Array.isArray(node.children) ? node.children : [];
|
|
52
|
+
if (options['github-corners-fork']) {
|
|
53
|
+
node.children.unshift(githubCornersFork({ href: options['github-corners'] }));
|
|
54
|
+
} else {
|
|
55
|
+
githubCorners({ href: options['github-corners'] }).forEach(item => {
|
|
56
|
+
node.children.unshift(item)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (node.type == 'element' && /h(1|2|3|4|5|6)/.test(node.tagName) && node.children && Array.isArray(node.children) && node.children.length > 0) {
|
|
61
|
+
const child = node.children[0];
|
|
62
|
+
if (child && child.type === 'element' && child.properties) {
|
|
63
|
+
child.properties = { className: 'anchor', ...child.properties };
|
|
64
|
+
child.children = [octiconLink()];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (node.type == 'element' && node.tagName === 'markdown-style') {
|
|
68
|
+
node.children.unshift(copyStyle())
|
|
69
|
+
node.children.unshift(copyScript())
|
|
70
|
+
}
|
|
71
|
+
if (node.type == 'element' && node.tagName === 'pre') {
|
|
72
|
+
const code = getCodeString(node.children);
|
|
73
|
+
node.children.push(copyElement(code));
|
|
74
|
+
}
|
|
75
|
+
if (rewrite && typeof rewrite === 'function') {
|
|
76
|
+
rewrite(node, index, parent);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (document) {
|
|
82
|
+
const documentOptions = { ...document };
|
|
83
|
+
if (document.js) {
|
|
84
|
+
documentOptions.js = Array.isArray(document.js) ? document.js : [document.js];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (document.script) {
|
|
88
|
+
documentOptions.script = Array.isArray(document.script) ? document.script : [document.script];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (document.link) {
|
|
92
|
+
documentOptions.link = Array.isArray(document.link) ? document.link : [document.link];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (document.style) {
|
|
96
|
+
documentOptions.style = Array.isArray(document.style) ? document.style : [document.style];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
mdOptions.rehypePlugins.unshift([rehypeDocument, documentOptions]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return markdown(string || '', mdOptions) as string;
|
|
103
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import minimist, { ParsedArgs } from 'minimist';
|
|
4
|
+
import { Options } from 'rehype-document';
|
|
5
|
+
import { RehypeRewriteOptions } from 'rehype-rewrite';
|
|
6
|
+
import { create, _dirname } from './create';
|
|
7
|
+
import { formatConfig } from './utils';
|
|
8
|
+
|
|
9
|
+
export * from './create';
|
|
10
|
+
export * from './utils';
|
|
11
|
+
|
|
12
|
+
export interface RunArgvs extends Omit<ParsedArgs, '_'> {
|
|
13
|
+
version?: string;
|
|
14
|
+
source?: string;
|
|
15
|
+
output?: string;
|
|
16
|
+
/** Add a Github corner to your project page. */
|
|
17
|
+
'github-corners'?: string;
|
|
18
|
+
/** Github corners style. */
|
|
19
|
+
'github-corners-fork'?: boolean;
|
|
20
|
+
'dark-mode'?: boolean;
|
|
21
|
+
/** Markdown string. */
|
|
22
|
+
markdown?: string;
|
|
23
|
+
/** The `<title>` tag is required in HTML documents! */
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Specify the configuration file. Default: `<process.cwd()>/package.json` */
|
|
26
|
+
config?: string;
|
|
27
|
+
/** Define a description of your web page */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Define keywords for search engines */
|
|
30
|
+
keywords?: string;
|
|
31
|
+
/** Add a Favicon to your Site */
|
|
32
|
+
favicon?: string;
|
|
33
|
+
/** Define the author of a page */
|
|
34
|
+
author?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface MDToHTMLOptions extends RunArgvs {
|
|
38
|
+
/** [rehype-document](https://github.com/rehypejs/rehype-document#options) options */
|
|
39
|
+
document?: Options;
|
|
40
|
+
/** */
|
|
41
|
+
darkMode?: boolean;
|
|
42
|
+
/** Rewrite Element. [rehype-rewrite](https://github.com/jaywcjlove/rehype-rewrite#rewritenode-index-parent-void) */
|
|
43
|
+
rewrite?: RehypeRewriteOptions['rewrite'];
|
|
44
|
+
/** rewrite URLs of href and src attributes. */
|
|
45
|
+
reurls?: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function run(opts = {} as Omit<RunArgvs, '_'>) {
|
|
49
|
+
const argvs = minimist<RunArgvs>(process.argv.slice(2), {
|
|
50
|
+
alias: {
|
|
51
|
+
help: 'h',
|
|
52
|
+
version: 'v',
|
|
53
|
+
config: 'c',
|
|
54
|
+
source: 's',
|
|
55
|
+
output: 'o',
|
|
56
|
+
},
|
|
57
|
+
default: {
|
|
58
|
+
version: opts.v || opts.version || false,
|
|
59
|
+
help: opts.h || opts.help || false,
|
|
60
|
+
source: opts.s || opts.source || 'README.md',
|
|
61
|
+
markdown: opts.markdown || '',
|
|
62
|
+
description: opts.description || '',
|
|
63
|
+
output: opts.o || opts.output || 'index.html',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
if (argvs.h || argvs.help) {
|
|
67
|
+
console.log(`${cliHelp}${exampleHelp}`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const pkgPath = path.resolve(_dirname, '..', 'package.json')
|
|
71
|
+
if ((argvs.v || argvs.version) && fs.existsSync(pkgPath)) {
|
|
72
|
+
const pkg = fs.readJSONSync(pkgPath);
|
|
73
|
+
console.log(`\n \x1b[35mmarkdown-to-html-cli\x1b[0m v${pkg.version}\n`);
|
|
74
|
+
return pkg.version;
|
|
75
|
+
}
|
|
76
|
+
if (argvs.source && !argvs.markdown) {
|
|
77
|
+
argvs.markdown = fs.readFileSync(path.resolve(argvs.source)).toString();
|
|
78
|
+
}
|
|
79
|
+
const options = formatConfig({ ...opts, ...argvs });
|
|
80
|
+
const output = path.resolve(argvs.output);
|
|
81
|
+
|
|
82
|
+
const strMarkdown = create({ ...argvs, ...options });
|
|
83
|
+
fs.writeFileSync(output, strMarkdown);
|
|
84
|
+
console.log(`\nmarkdown-to-html: \x1b[32;1m${path.relative(process.cwd(), output)}\x1b[0m\n`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const cliHelp: string = `\n Usage: markdown-to-html [options] [--help|h]
|
|
88
|
+
|
|
89
|
+
Options:\n
|
|
90
|
+
--author Define the author of a page.
|
|
91
|
+
--config, -o Specify the configuration file. Default: "<process.cwd()>/package.json".
|
|
92
|
+
--description Define a description of your web page.
|
|
93
|
+
--favicon Add a Favicon to your Site.
|
|
94
|
+
--github-corners Add a Github corner to your project page.
|
|
95
|
+
--github-corners-fork Github corners style.
|
|
96
|
+
--keywords Define keywords for search engines.
|
|
97
|
+
--no-dark-mode Disable light and dark theme styles button.
|
|
98
|
+
--markdown Markdown string.
|
|
99
|
+
--output, -o Output static pages to the specified directory. Default: "index.html"
|
|
100
|
+
--source, -s The path of the target file "README.md". Default: "README.md"
|
|
101
|
+
--title The \`<title>\` tag is required in HTML documents!
|
|
102
|
+
--version, -v Show version number
|
|
103
|
+
--help, -h Displays help information.
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
export const exampleHelp: string =`\n Example:
|
|
107
|
+
|
|
108
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli
|
|
109
|
+
\x1b[35mnpm\x1b[0m markdown-to-html \x1b[33m--title\x1b[0m="Hello World!"
|
|
110
|
+
\x1b[35mnpm\x1b[0m markdown-to-html \x1b[33m--config\x1b[0m="config/conf.json"
|
|
111
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--markdown\x1b[0m="Hello World!"
|
|
112
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--no-dark-mode\x1b[0m
|
|
113
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--github-corners\x1b[0m https://github.com/jaywcjlove/markdown-to-html-cli
|
|
114
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--github-corners\x1b[0m https://github.com/jaywcjlove --github-corners-fork
|
|
115
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--output\x1b[0m coverage/index.html
|
|
116
|
+
\x1b[35mnpm\x1b[0m markdown-to-html-cli \x1b[33m--source\x1b[0m README.md
|
|
117
|
+
|
|
118
|
+
`;
|