markdown-to-html-cli 3.2.11 → 3.2.14

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
@@ -20,7 +20,7 @@ Used in Github [Actions](https://github.com/actions).
20
20
  - run: markdown-to-html --source src/README.md --output coverage/index.html
21
21
  # or
22
22
  - name: Converts Markdown to HTML
23
- uses: jaywcjlove/github-action-contributors@main
23
+ uses: jaywcjlove/markdown-to-html-cli@main
24
24
  with:
25
25
  source: README-zh.md
26
26
  output: coverage/action.html
@@ -232,15 +232,6 @@ export interface MDToHTMLOptions extends RunArgvs {
232
232
  rewrite?: RehypeRewriteOptions['rewrite'];
233
233
  /** rewrite URLs of href and src attributes. */
234
234
  reurls?: Record<string, string>;
235
- /**
236
- * rehype-wrap Options
237
- * Wrap selected elements with a given element
238
- * https://github.com/mrzmmr/rehype-wrap/tree/2402bcdb8ea25bd0948cda72e96d16e65a18c1e9#options
239
- */
240
- wrap?: {
241
- selector?: string;
242
- wrapper?: string;
243
- };
244
235
  }
245
236
  export declare function run(opts?: Omit<RunArgvs, "_">): any;
246
237
  export declare const cliHelp: string;
package/lib/create.js CHANGED
@@ -1,108 +1,53 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { unified } from 'unified';
1
+ import markdown from '@wcj/markdown-to-html';
2
+ import { getCodeString } from 'rehype-rewrite';
4
3
  import rehypeDocument from 'rehype-document';
5
- // @ts-ignore
6
- import rehypePrism from '@mapbox/rehype-prism';
7
- import stringify from 'rehype-stringify';
8
- import rehypeSlug from 'rehype-slug';
9
- import rehypeFormat from 'rehype-format';
10
4
  import rehypeAutolinkHeadings from 'rehype-autolink-headings';
5
+ import rehypeSlug from 'rehype-slug';
6
+ import remarkGemoji from 'remark-gemoji';
11
7
  // @ts-ignore
12
8
  import rehypeUrls from 'rehype-urls';
13
- // @ts-ignore
14
- import rehypeWrap from 'rehype-wrap';
15
- import rehypeRaw from 'rehype-raw';
16
- import rehypeRewrite from 'rehype-rewrite';
17
- import rehypeAttrs from 'rehype-attr';
18
- import rehypeVideo from 'rehype-video';
19
- import remarkGfm from 'remark-gfm';
20
- import remarkGemoji from 'remark-gemoji';
21
- import remarkRehype from 'remark-rehype';
22
- import remarkParse from 'remark-parse';
23
- import { githubCorners } from './nodes/githubCorners.js';
24
- import { githubCornersFork } from './nodes/githubCornersFork.js';
9
+ import rehypeFormat from 'rehype-format';
10
+ import { githubCorners } from './nodes/github-corners.js';
11
+ import { githubCornersFork } from './nodes/github-corners-fork.js';
25
12
  import { octiconLink } from './nodes/octiconLink.js';
26
- import { copyElement } from './nodes/copy.js';
13
+ import { markdownStyle } from './nodes/markdown-style.js';
14
+ import { copyElement, copyStyle, copyScript } from './nodes/copy.js';
15
+ import { darkMode } from './nodes/dark-mode.js';
27
16
  // https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-when-using-the-experimental-modules-flag
28
17
  // export const _dirname = dirname(fileURLToPath(import.meta.url));
29
18
  // const filename = fileURLToPath(import.meta.url);
30
19
  // const dirname = path.dirname(filename);
31
20
  export const _dirname = /file:\/\/(.+)\/[^/]/.exec(import.meta.url)[1];
32
- const script = `/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
33
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).copyTextToClipboard=t()}(this,(function(){"use strict";return function(e,t){const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style={position:"absolute",left:"-9999px"},document.body.appendChild(o);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);o.select();let c=!1;try{c=!!document.execCommand("copy")}catch(e){c=!1}document.body.removeChild(o),n&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n)),t&&t(c)}}));
34
-
35
- function copied(target, str) {
36
- target.classList.add('active');
37
- copyTextToClipboard(target.dataset.code, function() {
38
- setTimeout(() => {
39
- target.classList.remove('active');
40
- }, 2000);
41
- });
42
- }`;
43
- const getCodeStr = (data = [], code = '') => {
44
- data.forEach((node) => {
45
- if (node.type === 'text') {
46
- code += node.value;
47
- }
48
- else if (node.type === 'element' && node.children && Array.isArray(node.children)) {
49
- code += getCodeStr(node.children);
50
- }
51
- });
52
- return code;
53
- };
54
21
  export function create(options = {}) {
55
- const { markdown, document, rewrite, reurls = {}, wrap = { wrapper: 'div.markdown-body' } } = options;
56
- // default github css.
57
- const cssPath = path.resolve(_dirname, '..', 'github.css');
58
- const cssForkPath = path.resolve(_dirname, '..', 'github-fork-ribbon.css');
59
- let cssStr = '';
60
- if (fs.existsSync(cssPath)) {
61
- cssStr = fs.readFileSync(cssPath).toString();
62
- }
63
- if (options['github-corners-fork'] && options['github-corners'] && fs.existsSync(cssForkPath)) {
64
- let cssFork = fs.readFileSync(cssForkPath).toString();
65
- cssStr = `${cssStr}${cssFork}`;
66
- }
67
- return unified()
68
- .use(remarkParse)
69
- .use(remarkGfm)
70
- .use(remarkGemoji)
71
- .use(remarkRehype, { allowDangerousHtml: true })
72
- .use(rehypeVideo)
73
- .use(rehypeRaw)
74
- .use(document ? rehypeDocument : undefined, {
75
- ...document,
76
- js: [
77
- ...(document && document.js ? (Array.isArray(document.js) ? document.js : [document.js]) : []),
78
- ],
79
- script: [
80
- ...(document && document.script ? (Array.isArray(document.script) ? document.script : [document.script]) : []),
81
- script,
22
+ const { markdown: string, document, rewrite, reurls = {} } = options;
23
+ const mdOptions = {
24
+ hastNode: false,
25
+ remarkPlugins: [remarkGemoji],
26
+ rehypePlugins: [
27
+ [rehypeUrls, (url) => {
28
+ if (reurls[url.href]) {
29
+ url.path = reurls[url.href];
30
+ return url.path;
31
+ }
32
+ }],
33
+ [rehypeSlug],
34
+ [rehypeAutolinkHeadings],
35
+ [rehypeFormat],
82
36
  ],
83
- link: document && document.link ? (Array.isArray(document.link) ? document.link : [document.link]) : [],
84
- style: [cssStr.toString().replace(/\n/g, ''), ...(document ? (Array.isArray(document.style) ? document.style : [document.style]) : [])],
85
- })
86
- .use(rehypeSlug)
87
- .use(rehypeAutolinkHeadings)
88
- .use(rehypeWrap, { ...wrap })
89
- .use(rehypePrism, { ignoreMissing: true })
90
- .use(rehypeAttrs, { properties: 'attr' })
91
- .use(rehypeUrls, (url) => {
92
- if (reurls[url.href]) {
93
- url.path = reurls[url.href];
94
- return url.path;
95
- }
96
- })
97
- .use(rehypeRewrite, {
98
37
  rewrite: (node, index, parent) => {
38
+ if ((node.type == 'element' && node.tagName === 'body') || (!document && node.type === 'root')) {
39
+ node.children = markdownStyle(node.children);
40
+ darkMode().forEach(item => node.children.unshift(item));
41
+ }
99
42
  if (options['github-corners'] && ((document && node.type == 'element' && node.tagName === 'body') || (!document && node.type === 'root'))) {
100
43
  node.children = Array.isArray(node.children) ? node.children : [];
101
44
  if (options['github-corners-fork']) {
102
45
  node.children.unshift(githubCornersFork({ href: options['github-corners'] }));
103
46
  }
104
47
  else {
105
- node.children.unshift(githubCorners({ href: options['github-corners'] }));
48
+ githubCorners({ href: options['github-corners'] }).forEach(item => {
49
+ node.children.unshift(item);
50
+ });
106
51
  }
107
52
  }
108
53
  if (node.type == 'element' && /h(1|2|3|4|5|6)/.test(node.tagName) && node.children && Array.isArray(node.children) && node.children.length > 0) {
@@ -112,18 +57,35 @@ export function create(options = {}) {
112
57
  child.children = [octiconLink()];
113
58
  }
114
59
  }
60
+ if (node.type == 'element' && node.tagName === 'markdown-style') {
61
+ node.children.unshift(copyStyle());
62
+ node.children.unshift(copyScript());
63
+ }
115
64
  if (node.type == 'element' && node.tagName === 'pre') {
116
- const code = getCodeStr(node.children);
65
+ const code = getCodeString(node.children);
117
66
  node.children.push(copyElement(code));
118
67
  }
119
68
  if (rewrite && typeof rewrite === 'function') {
120
69
  rewrite(node, index, parent);
121
70
  }
122
71
  }
123
- })
124
- .use(rehypeFormat)
125
- .use(stringify)
126
- .processSync(markdown)
127
- .toString();
72
+ };
73
+ if (document) {
74
+ const documentOptions = { ...document };
75
+ if (document.js) {
76
+ documentOptions.js = Array.isArray(document.js) ? document.js : [document.js];
77
+ }
78
+ if (document.script) {
79
+ documentOptions.script = Array.isArray(document.script) ? document.script : [document.script];
80
+ }
81
+ if (document.link) {
82
+ documentOptions.link = Array.isArray(document.link) ? document.link : [document.link];
83
+ }
84
+ if (document.style) {
85
+ documentOptions.style = Array.isArray(document.style) ? document.style : [document.style];
86
+ }
87
+ mdOptions.rehypePlugins.unshift([rehypeDocument, documentOptions]);
88
+ }
89
+ return markdown(string || '', mdOptions);
128
90
  }
129
91
  //# sourceMappingURL=create.js.map
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,aAAa;AACb,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,aAAa;AACb,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,aAAa;AACb,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,YAAY,MAAM,eAAe,CAAC;AACz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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
@@ -33,15 +33,6 @@ export interface MDToHTMLOptions extends RunArgvs {
33
33
  rewrite?: RehypeRewriteOptions['rewrite'];
34
34
  /** rewrite URLs of href and src attributes. */
35
35
  reurls?: Record<string, string>;
36
- /**
37
- * rehype-wrap Options
38
- * Wrap selected elements with a given element
39
- * https://github.com/mrzmmr/rehype-wrap/tree/2402bcdb8ea25bd0948cda72e96d16e65a18c1e9#options
40
- */
41
- wrap?: {
42
- selector?: string;
43
- wrapper?: string;
44
- };
45
36
  }
46
37
  export declare function run(opts?: Omit<RunArgvs, "_">): any;
47
38
  export declare const cliHelp: string;
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,QAAQ,EAAE,MAAM,UAA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AAC,OAAO,CAAC;KACpB;IACD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KACzE;IACD,MAAM,OAAO,GAAG,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE1C,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;;;;;;;;;;;;;;;;CAgB9B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAU;;;;;;;;;;;CAWjC,CAAC"}
@@ -1,2 +1,4 @@
1
1
  import { Element } from 'hast';
2
+ export declare function copyStyle(): Element;
3
+ export declare function copyScript(): Element;
2
4
  export declare function copyElement(str?: string): Element;
package/lib/nodes/copy.js CHANGED
@@ -1,4 +1,79 @@
1
- export function copyElement(str = 'test') {
1
+ const style = `.markdown-body pre .copied {
2
+ display: flex;
3
+ position: absolute;
4
+ cursor: pointer;
5
+ color: #a5afbb;
6
+ top: 6px;
7
+ right: 6px;
8
+ border-radius: 5px;
9
+ background: #82828226;
10
+ padding: 6px;
11
+ font-size: 12px;
12
+ transition: all .3s;
13
+ }
14
+ .markdown-body pre .copied:not(.active) {
15
+ visibility: hidden;
16
+ }
17
+ .markdown-body pre:hover .copied {
18
+ visibility: visible;
19
+ }
20
+ .markdown-body pre:hover .copied:hover {
21
+ background: #4caf50;
22
+ color: #fff;
23
+ }
24
+ .markdown-body pre:hover .copied:active,
25
+ .markdown-body pre .copied.active {
26
+ background: #2e9b33;
27
+ color: #fff;
28
+ }
29
+ .markdown-body pre .copied .octicon-copy {
30
+ display: block;
31
+ }
32
+ .markdown-body pre .copied .octicon-check {
33
+ display: none;
34
+ }
35
+ .markdown-body pre .active .octicon-copy {
36
+ display: none;
37
+ }
38
+ .markdown-body pre .active .octicon-check {
39
+ display: block;
40
+ }`;
41
+ export function copyStyle() {
42
+ return {
43
+ type: 'element',
44
+ tagName: 'style',
45
+ children: [
46
+ {
47
+ type: 'text',
48
+ value: style
49
+ }
50
+ ]
51
+ };
52
+ }
53
+ const script = `/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
54
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).copyTextToClipboard=t()}(this,(function(){"use strict";return function(e,t){const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style={position:"absolute",left:"-9999px"},document.body.appendChild(o);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);o.select();let c=!1;try{c=!!document.execCommand("copy")}catch(e){c=!1}document.body.removeChild(o),n&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n)),t&&t(c)}}));
55
+
56
+ function copied(target, str) {
57
+ target.classList.add('active');
58
+ copyTextToClipboard(target.dataset.code, function() {
59
+ setTimeout(() => {
60
+ target.classList.remove('active');
61
+ }, 2000);
62
+ });
63
+ }`;
64
+ export function copyScript() {
65
+ return {
66
+ type: 'element',
67
+ tagName: 'script',
68
+ children: [
69
+ {
70
+ type: 'text',
71
+ value: script
72
+ }
73
+ ]
74
+ };
75
+ }
76
+ export function copyElement(str = '') {
2
77
  return {
3
78
  type: 'element',
4
79
  tagName: 'div',
@@ -1 +1 @@
1
- {"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/nodes/copy.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,MAAc,MAAM;IAC9C,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;QACd,UAAU,EAAE;YACV,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,GAAG;YAChB,SAAS,EAAE,QAAQ;SACpB;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE,cAAc;oBACzB,UAAU,EAAE,MAAM;oBAClB,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,cAAc;oBACpB,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,EAAE;iBACV;gBACD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE;4BACV,QAAQ,EAAE,SAAS;4BACnB,CAAC,EAAE,2MAA2M;yBAC/M;wBACD,QAAQ,EAAE,EAAE;qBACb,EAAE;wBACD,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE;4BACV,QAAQ,EAAE,SAAS;4BACnB,CAAC,EAAE,iOAAiO;yBACrO;wBACD,QAAQ,EAAE,EAAE;qBACb;iBACF;aACF;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE,eAAe;oBAC1B,UAAU,EAAE,MAAM;oBAClB,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,cAAc;oBACpB,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,EAAE;iBACV;gBACD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,SAAS;wBAC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wBACf,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE;4BACV,QAAQ,EAAE,SAAS;4BACnB,CAAC,EAAE,2MAA2M;yBAC/M;wBACD,QAAQ,EAAE,EAAE;qBACb,EAAE;wBACD,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE;4BACV,QAAQ,EAAE,SAAS;4BACnB,CAAC,EAAE,iOAAiO;yBACrO;wBACD,QAAQ,EAAE,EAAE;qBACb;iBACF;aACF;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE,eAAe;oBAC1B,UAAU,EAAE,MAAM;oBAClB,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,cAAc;oBACpB,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,EAAE;iBACV;gBACD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE;4BACV,QAAQ,EAAE,SAAS;4BACnB,CAAC,EAAE,iIAAiI;yBACrI;wBACD,QAAQ,EAAE,EAAE;qBACb;iBACF;aACF;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Element } from 'hast';
2
+ /**
3
+ * @wcj/dark-mode@1.0.14
4
+ * https://github.com/jaywcjlove/dark-mode
5
+ */
6
+ export declare function darkMode(): Element[];
@@ -0,0 +1,29 @@
1
+ const scriptString = `const t=document;const e="_dark_mode_theme_";const s="permanent";const o="colorschemechange";const i="permanentcolorscheme";const h="light";const r="dark";const n=(t,e,s=e)=>{Object.defineProperty(t,s,{enumerable:true,get(){const t=this.getAttribute(e);return t===null?"":t},set(t){this.setAttribute(e,t)}})};const c=(t,e,s=e)=>{Object.defineProperty(t,s,{enumerable:true,get(){return this.hasAttribute(e)},set(t){if(t){this.setAttribute(e,"")}else{this.removeAttribute(e)}}})};class a extends HTMLElement{static get observedAttributes(){return["mode",h,r,s]}LOCAL_NANE=e;constructor(){super();this.t()}connectedCallback(){n(this,"mode");n(this,r);n(this,h);c(this,s);const a=localStorage.getItem(e);if(a&&[h,r].includes(a)){this.mode=a;this.permanent=true}if(this.permanent&&!a){localStorage.setItem(e,this.mode)}const l=[h,r].includes(a);if(this.permanent&&a){this.o()}else{if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches){this.mode=r;this.o()}if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches){this.mode=h;this.o()}}if(!this.permanent&&!l){window.matchMedia("(prefers-color-scheme: light)").onchange=t=>{this.mode=t.matches?h:r;this.o()};window.matchMedia("(prefers-color-scheme: dark)").onchange=t=>{this.mode=t.matches?r:h;this.o()}}const d=new MutationObserver(((s,h)=>{this.mode=t.documentElement.dataset.colorMode;if(this.permanent&&l){localStorage.setItem(e,this.mode);this.i(i,{permanent:this.permanent})}this.h();this.i(o,{colorScheme:this.mode})}));d.observe(t.documentElement,{attributes:true});this.i(o,{colorScheme:this.mode});this.h()}attributeChangedCallback(t,s,o){if(t==="mode"&&s!==o&&[h,r].includes(o)){const t=localStorage.getItem(e);if(this.mode===t){this.mode=o;this.h();this.o()}else if(this.mode&&this.mode!==t){this.h();this.o()}}else if((t===h||t===r)&&s!==o){this.h()}if(t==="permanent"&&typeof this.permanent==="boolean"){this.permanent?localStorage.setItem(e,this.mode):localStorage.removeItem(e)}}o(){t.documentElement.setAttribute("data-color-mode",this.mode)}h(){this.icon.textContent=this.mode===h?"🌒":"🌞";this.text.textContent=this.mode===h?this.getAttribute(r):this.getAttribute(h)}t(){var s=this.attachShadow({mode:"open"});this.label=t.createElement("span");this.label.setAttribute("class","wrapper");this.label.onclick=()=>{this.mode=this.mode===h?r:h;if(this.permanent){localStorage.setItem(e,this.mode)}this.o();this.h()};s.appendChild(this.label);this.icon=t.createElement("span");this.label.appendChild(this.icon);this.text=t.createElement("span");this.label.appendChild(this.text);const o=\`\n[data-color-mode*='dark'], [data-color-mode*='dark'] body {\n color-scheme: dark;\n --color-theme-bg: #0d1117;\n --color-theme-text: #c9d1d9;\n background-color: var(--color-theme-bg);\n color: var(--color-theme-text);\n}\n\n[data-color-mode*='light'], [data-color-mode*='light'] body {\n color-scheme: light;\n --color-theme-bg: #fff;\n --color-theme-text: #24292f;\n background-color: var(--color-theme-bg);\n color: var(--color-theme-text);\n}\`;const i="_dark_mode_style_";const n=t.getElementById(i);if(!n){var c=t.createElement("style");c.id=i;c.textContent=o;t.head.appendChild(c)}var a=t.createElement("style");a.textContent=\`\n .wrapper { cursor: pointer; user-select: none; position: relative; }\n .wrapper > span + span { margin-left: .4rem; }\n \`;s.appendChild(a)}i(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:true,composed:true,detail:e}))}}customElements.define("dark-mode",a);`;
2
+ /**
3
+ * @wcj/dark-mode@1.0.14
4
+ * https://github.com/jaywcjlove/dark-mode
5
+ */
6
+ export function darkMode() {
7
+ return [{
8
+ type: 'element',
9
+ tagName: 'script',
10
+ // properties: {
11
+ // src: 'https://unpkg.com/@wcj/dark-mode',
12
+ // },
13
+ children: [{
14
+ type: 'text',
15
+ value: scriptString,
16
+ }]
17
+ }, {
18
+ type: 'element',
19
+ tagName: 'dark-mode',
20
+ properties: {
21
+ permanent: true,
22
+ style: 'position: fixed; top: 8px; left: 10px; z-index: 999;',
23
+ dark: 'Dark',
24
+ light: 'Light',
25
+ },
26
+ children: []
27
+ }];
28
+ }
29
+ //# sourceMappingURL=dark-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dark-mode.js","sourceRoot":"","sources":["../../src/nodes/dark-mode.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,o8GAAo8G,CAAA;AAEz9G;;;GAGG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC;YACN,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,QAAQ;YACjB,gBAAgB;YAChB,6CAA6C;YAC7C,KAAK;YACL,QAAQ,EAAE,CAAC;oBACT,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,YAAY;iBACpB,CAAC;SACH,EAAE;YACD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,WAAW;YACpB,UAAU,EAAE;gBACV,SAAS,EAAE,IAAI;gBACf,KAAK,EAAE,sDAAsD;gBAC7D,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,OAAO;aACf;YACD,QAAQ,EAAE,EAAE;SACb,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,122 @@
1
+ const style = `.github-fork-ribbon {
2
+ width: 12.1em;
3
+ height: 12.1em;
4
+ position: absolute;
5
+ overflow: hidden;
6
+ top: 0;
7
+ right: 0;
8
+ z-index: 9999;
9
+ pointer-events: none;
10
+ font-size: 13px;
11
+ text-decoration: none;
12
+ text-indent: -999999px;
13
+ }
14
+
15
+ .github-fork-ribbon.fixed {
16
+ position: fixed;
17
+ }
18
+
19
+ .github-fork-ribbon:hover, .github-fork-ribbon:active {
20
+ background-color: rgba(0, 0, 0, 0.0);
21
+ }
22
+
23
+ .github-fork-ribbon:before, .github-fork-ribbon:after {
24
+ /* The right and left classes determine the side we attach our banner to */
25
+ position: absolute;
26
+ display: block;
27
+ width: 15.38em;
28
+ height: 1.54em;
29
+
30
+ top: 3.23em;
31
+ right: -3.23em;
32
+
33
+ -webkit-box-sizing: content-box;
34
+ -moz-box-sizing: content-box;
35
+ box-sizing: content-box;
36
+
37
+ -webkit-transform: rotate(45deg);
38
+ -moz-transform: rotate(45deg);
39
+ -ms-transform: rotate(45deg);
40
+ -o-transform: rotate(45deg);
41
+ transform: rotate(45deg);
42
+ }
43
+
44
+ .github-fork-ribbon:before {
45
+ content: "";
46
+
47
+ /* Add a bit of padding to give some substance outside the "stitching" */
48
+ padding: .38em 0;
49
+
50
+ /* Set the base colour */
51
+ background-color: #a00;
52
+
53
+ /* Set a gradient: transparent black at the top to almost-transparent black at the bottom */
54
+ background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.15)));
55
+ background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));
56
+ background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));
57
+ background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));
58
+ background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));
59
+ background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));
60
+
61
+ /* Add a drop shadow */
62
+ -webkit-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);
63
+ -moz-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);
64
+ box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5);
65
+
66
+ pointer-events: auto;
67
+ }
68
+
69
+ .github-fork-ribbon:after {
70
+ /* Set the text from the data-ribbon attribute */
71
+ content: attr(data-ribbon);
72
+
73
+ /* Set the text properties */
74
+ color: #fff;
75
+ font: 700 1em "Helvetica Neue", Helvetica, Arial, sans-serif;
76
+ line-height: 1.54em;
77
+ text-decoration: none;
78
+ text-shadow: 0 -.08em rgba(0, 0, 0, 0.5);
79
+ text-align: center;
80
+ text-indent: 0;
81
+
82
+ /* Set the layout properties */
83
+ padding: .15em 0;
84
+ margin: .15em 0;
85
+
86
+ /* Add "stitching" effect */
87
+ border-width: .08em 0;
88
+ border-style: dotted;
89
+ border-color: #fff;
90
+ border-color: rgba(255, 255, 255, 0.7);
91
+ }`;
92
+ export function githubCornersFork(opts) {
93
+ const { href } = opts;
94
+ if (!href) {
95
+ return;
96
+ }
97
+ return {
98
+ type: 'element',
99
+ tagName: 'a',
100
+ properties: {
101
+ 'aria-label': 'Fork me on Github',
102
+ title: 'Fork me on GitHub',
103
+ target: '__blank',
104
+ className: 'github-fork-ribbon',
105
+ 'data-ribbon': 'Fork me on GitHub',
106
+ href,
107
+ },
108
+ children: [
109
+ {
110
+ type: 'element',
111
+ tagName: 'style',
112
+ children: [
113
+ {
114
+ type: 'text',
115
+ value: style
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ };
121
+ }
122
+ //# sourceMappingURL=github-corners-fork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-corners-fork.js","sourceRoot":"","sources":["../../src/nodes/github-corners-fork.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0FZ,CAAC;AAMH,MAAM,UAAU,iBAAiB,CAAC,IAAmB;IACnD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,IAAI,EAAE;QACT,OAAO;KACR;IACD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,GAAG;QACZ,UAAU,EAAE;YACV,YAAY,EAAE,mBAAmB;YACjC,KAAK,EAAE,mBAAmB;YAC1B,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,oBAAoB;YAC/B,aAAa,EAAE,mBAAmB;YAClC,IAAI;SACL;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE,KAAK;qBACb;iBACF;aACF;SACF;KACF,CAAA;AACH,CAAC"}
@@ -2,5 +2,5 @@ import { Element } from 'hast';
2
2
  interface GithubCorners {
3
3
  href?: string;
4
4
  }
5
- export declare function githubCorners(opts: GithubCorners): Element;
5
+ export declare function githubCorners(opts: GithubCorners): Element[];
6
6
  export {};