@lyhue1991/wxgzh 0.2.1 → 0.2.3

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
@@ -6,7 +6,13 @@
6
6
 
7
7
  <mark>安装此SKILL</mark>
8
8
 
9
+ ```bash
10
+ #for openclaw
11
+ npx clawhub@latest install wxgzh
9
12
  ```
13
+
14
+ ```bash
15
+ #for opencode/claudecode/cursor/openclaw/...
10
16
  npx skills add lyhue1991/wxgzh
11
17
  ```
12
18
 
@@ -18,7 +18,7 @@ async function convertMarkdownFile(inputPath, outputPath, options) {
18
18
  const raw = await (0, promises_1.readFile)(absoluteInputPath, 'utf8');
19
19
  const parsed = (0, parser_1.parseMarkdown)(raw);
20
20
  const config = await (0, config_1.loadConfig)({ account: options?.account ?? parsed.metadata.account });
21
- const resolvedTheme = options?.theme ?? parsed.metadata.theme ?? config.defaultTheme ?? 'default';
21
+ const resolvedTheme = options?.theme ?? parsed.metadata.theme ?? config.defaultTheme ?? (0, themes_1.getDefaultThemeName)();
22
22
  const html = await (0, converter_1.renderMarkdownToHtml)(parsed.body, {
23
23
  ...parsed.metadata,
24
24
  account: options?.account ?? parsed.metadata.account ?? config.account,
@@ -478,12 +478,30 @@ function normalizeListItems($) {
478
478
  });
479
479
  const firstChild = childElements[0];
480
480
  if (!hasBlockChild && isTagNode(firstChild, 'span') && childElements.length === 1) {
481
+ $(firstChild).attr('data-wxgzh', 'li-inline');
481
482
  return;
482
483
  }
483
484
  if (hasBlockChild) {
485
+ const inlineNodes = [];
486
+ for (const node of childElements) {
487
+ if (node.type === 'tag') {
488
+ const tagName = node.tagName.toLowerCase();
489
+ if (['p', 'ul', 'ol', 'section', 'blockquote', 'pre', 'table'].includes(tagName)) {
490
+ break;
491
+ }
492
+ }
493
+ inlineNodes.push(node);
494
+ }
495
+ if (inlineNodes.length > 0) {
496
+ const inlineHtml = inlineNodes.map((node) => $.html(node)).join('');
497
+ for (const node of inlineNodes) {
498
+ $(node).remove();
499
+ }
500
+ $item.prepend(`<span data-wxgzh="li-inline">${inlineHtml}</span>`);
501
+ }
484
502
  return;
485
503
  }
486
- $item.html(`<span>${$item.html() ?? ''}</span>`);
504
+ $item.html(`<span data-wxgzh="li-inline">${$item.html() ?? ''}</span>`);
487
505
  });
488
506
  }
489
507
  function normalizeImages($) {
@@ -700,6 +718,38 @@ function normalizeInlinedListStyles($) {
700
718
  $item.removeAttr('style');
701
719
  });
702
720
  }
721
+ function decorateUnorderedListMarkers($) {
722
+ $('ul').each((_, element) => {
723
+ const $list = $(element);
724
+ const depth = $list.parents('ul').length;
725
+ const paddingLeft = depth === 0 ? '0 !important' : '1.2em !important';
726
+ $list.attr('style', setInlineStyleProperty($list.attr('style'), 'list-style', 'none !important'));
727
+ $list.attr('style', setInlineStyleProperty($list.attr('style'), 'margin-left', '0 !important'));
728
+ $list.attr('style', setInlineStyleProperty($list.attr('style'), 'padding-left', paddingLeft));
729
+ });
730
+ $('ul > li').each((_, element) => {
731
+ const $item = $(element);
732
+ const hasCheckbox = $item.children('input[type="checkbox"]').length > 0;
733
+ if (hasCheckbox) {
734
+ return;
735
+ }
736
+ $item.children('span[data-wxgzh="ul-marker"]').remove();
737
+ $item.attr('style', setInlineStyleProperty($item.attr('style'), 'list-style', 'none !important'));
738
+ $item.attr('style', setInlineStyleProperty($item.attr('style'), 'margin-left', '0 !important'));
739
+ const $content = $item.children('span[data-wxgzh="li-inline"]').first();
740
+ if ($content.length === 0) {
741
+ return;
742
+ }
743
+ $content.children('span[data-wxgzh="ul-marker"]').remove();
744
+ $content.prepend('<span data-wxgzh="ul-marker">●&nbsp;</span>');
745
+ const $marker = $content.children('span[data-wxgzh="ul-marker"]').first();
746
+ $marker.attr('style', setInlineStyleProperty($marker.attr('style'), 'display', 'inline !important'));
747
+ $marker.attr('style', setInlineStyleProperty($marker.attr('style'), 'line-height', 'inherit !important'));
748
+ $marker.attr('style', setInlineStyleProperty($marker.attr('style'), 'font-size', '1.1em !important'));
749
+ $marker.attr('style', setInlineStyleProperty($marker.attr('style'), 'font-weight', '700 !important'));
750
+ $marker.attr('style', setInlineStyleProperty($marker.attr('style'), 'color', '#000000 !important'));
751
+ });
752
+ }
703
753
  function removeWechatUnsafeListWhitespace($) {
704
754
  $('ol, ul').each((_, element) => {
705
755
  $(element)
@@ -807,6 +857,7 @@ function cleanInlinedHtml(html) {
807
857
  $element.html(renderWechatFriendlyCodeHtml($element.contents().toArray()));
808
858
  });
809
859
  normalizeInlinedListStyles($);
860
+ decorateUnorderedListMarkers($);
810
861
  removeWechatUnsafeListWhitespace($);
811
862
  normalizeWechatCodeBlocks($);
812
863
  const $article = $('body > #write > article').first();
@@ -9,7 +9,7 @@ exports.assertThemeExists = assertThemeExists;
9
9
  exports.getDefaultThemeName = getDefaultThemeName;
10
10
  const node_fs_1 = require("node:fs");
11
11
  const node_path_1 = __importDefault(require("node:path"));
12
- const DEFAULT_THEME = 'default';
12
+ const DEFAULT_THEME = 'black';
13
13
  function getStylesDir() {
14
14
  return node_path_1.default.resolve(__dirname, '../../styles');
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyhue1991/wxgzh",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Markdown to WeChat Official Account draft CLI",
5
5
  "license": "MIT",
6
6
  "main": "dist/cli/index.js",
package/styles/black.css CHANGED
@@ -70,17 +70,23 @@ h1 {
70
70
  }
71
71
 
72
72
  h2{
73
- font-size: 25px;
74
- padding: 10px 10px 10px 10px;
75
- line-height: 1.15;
73
+ display: block;
74
+ width: 100%;
75
+ font-size: 18px;
76
+ font-weight: 800;
77
+ padding: 8px 14px;
78
+ line-height: 1.4;
76
79
  margin-top: 1.85em;
77
80
  margin-bottom: 1.15em;
78
- background:#000;
79
- color:#fff;
81
+ margin-left: 0;
82
+ border-bottom: none;
83
+ box-sizing: border-box;
84
+ background: #000;
85
+ color: #fff;
80
86
  }
81
87
 
82
88
  h3 {
83
- font-size: 20px;
89
+ font-size: 16px;
84
90
  line-height: 1.15;
85
91
  margin-top: 2.285714em;
86
92
  margin-bottom: 1.15em;
package/styles/blue.css CHANGED
@@ -71,20 +71,26 @@ h1 {
71
71
  }
72
72
 
73
73
  h2{
74
- font-size: 25px;
75
- padding: 10px 10px 10px 10px; /* 上、右、下、左的内边距分别为10px、20px、15px、25px */
76
- line-height: 1.15;
74
+ display: block;
75
+ width: 100%;
76
+ font-size: 18px;
77
+ font-weight: 800;
78
+ padding: 8px 14px;
79
+ line-height: 1.4;
77
80
  /*24 / 21*/
78
81
  margin-top: 1.85em;
79
82
  /*48 / 21*/
80
83
  margin-bottom: 1.15em;
81
84
  /*24 / 21*/
82
- background:#2891DB;
83
- color:#fff;
85
+ margin-left: 0;
86
+ border-bottom: none;
87
+ box-sizing: border-box;
88
+ background:#2891DB;
89
+ color:#fff;
84
90
  }
85
91
 
86
92
  h3 {
87
- font-size: 20px;
93
+ font-size: 16px;
88
94
  /*21 / 16*/
89
95
  line-height: 1.15;
90
96
  /*24 / 21*/
package/styles/brown.css CHANGED
@@ -70,17 +70,23 @@ h1 {
70
70
  }
71
71
 
72
72
  h2{
73
- font-size: 25px;
74
- padding: 10px 10px 10px 10px;
75
- line-height: 1.15;
73
+ display: block;
74
+ width: 100%;
75
+ font-size: 18px;
76
+ font-weight: 800;
77
+ padding: 8px 14px;
78
+ line-height: 1.4;
76
79
  margin-top: 1.85em;
77
80
  margin-bottom: 1.15em;
78
- background:#D27D2D;
79
- color:#fff;
81
+ margin-left: 0;
82
+ border-bottom: none;
83
+ box-sizing: border-box;
84
+ background:#D27D2D;
85
+ color:#fff;
80
86
  }
81
87
 
82
88
  h3 {
83
- font-size: 20px;
89
+ font-size: 16px;
84
90
  line-height: 1.15;
85
91
  margin-top: 2.285714em;
86
92
  margin-bottom: 1.15em;
@@ -69,17 +69,23 @@ h1 {
69
69
  }
70
70
 
71
71
  h2{
72
- font-size: 25px;
73
- padding: 10px 10px 10px 10px;
74
- line-height: 1.15;
72
+ display: block;
73
+ width: 100%;
74
+ font-size: 18px;
75
+ font-weight: 800;
76
+ padding: 8px 14px;
77
+ line-height: 1.4;
75
78
  margin-top: 1.85em;
76
79
  margin-bottom: 1.15em;
77
- background:#349971;
78
- color:#fff;
80
+ margin-left: 0;
81
+ border-bottom: none;
82
+ box-sizing: border-box;
83
+ background:#349971;
84
+ color:#fff;
79
85
  }
80
86
 
81
87
  h3 {
82
- font-size: 20px;
88
+ font-size: 16px;
83
89
  line-height: 1.15;
84
90
  margin-top: 2.285714em;
85
91
  margin-bottom: 1.15em;
package/styles/green.css CHANGED
@@ -72,20 +72,26 @@ h1 {
72
72
  }
73
73
 
74
74
  h2{
75
- font-size: 25px;
76
- padding: 10px 10px 10px 10px; /* 上、右、下、左的内边距分别为10px、20px、15px、25px */
77
- line-height: 1.15;
75
+ display: block;
76
+ width: 100%;
77
+ font-size: 18px;
78
+ font-weight: 800;
79
+ padding: 8px 14px;
80
+ line-height: 1.4;
78
81
  /*24 / 21*/
79
82
  margin-top: 1.85em;
80
83
  /*48 / 21*/
81
84
  margin-bottom: 1.15em;
82
85
  /*24 / 21*/
83
- background:#7FFF06;
84
- color:#fff;
86
+ margin-left: 0;
87
+ border-bottom: none;
88
+ box-sizing: border-box;
89
+ background:#7FFF06;
90
+ color:#fff;
85
91
  }
86
92
 
87
93
  h3 {
88
- font-size: 20px;
94
+ font-size: 16px;
89
95
  /*21 / 16*/
90
96
  line-height: 1.15;
91
97
  /*24 / 21*/
package/styles/orange.css CHANGED
@@ -72,20 +72,26 @@ h1 {
72
72
  }
73
73
 
74
74
  h2{
75
- font-size: 25px;
76
- padding: 10px 10px 10px 10px; /* 上、右、下、左的内边距分别为10px、20px、15px、25px */
77
- line-height: 1.15;
75
+ display: block;
76
+ width: 100%;
77
+ font-size: 18px;
78
+ font-weight: 800;
79
+ padding: 8px 14px;
80
+ line-height: 1.4;
78
81
  /*24 / 21*/
79
82
  margin-top: 1.85em;
80
83
  /*48 / 21*/
81
84
  margin-bottom: 1.15em;
82
85
  /*24 / 21*/
83
- background:#F7BC0A;
84
- color:#fff;
86
+ margin-left: 0;
87
+ border-bottom: none;
88
+ box-sizing: border-box;
89
+ background:#F7BC0A;
90
+ color:#fff;
85
91
  }
86
92
 
87
93
  h3 {
88
- font-size: 20px;
94
+ font-size: 16px;
89
95
  /*21 / 16*/
90
96
  line-height: 1.15;
91
97
  /*24 / 21*/
package/styles/red.css CHANGED
@@ -72,20 +72,26 @@ h1 {
72
72
  }
73
73
 
74
74
  h2{
75
- font-size: 25px;
76
- padding: 10px 10px 10px 10px; /* 上、右、下、左的内边距分别为10px、20px、15px、25px */
77
- line-height: 1.15;
75
+ display: block;
76
+ width: 100%;
77
+ font-size: 18px;
78
+ font-weight: 800;
79
+ padding: 8px 14px;
80
+ line-height: 1.4;
78
81
  /*24 / 21*/
79
82
  margin-top: 1.85em;
80
83
  /*48 / 21*/
81
84
  margin-bottom: 1.15em;
82
85
  /*24 / 21*/
83
- background:#DC143C;
84
- color:#fff;
86
+ margin-left: 0;
87
+ border-bottom: none;
88
+ box-sizing: border-box;
89
+ background:#DC143C;
90
+ color:#fff;
85
91
  }
86
92
 
87
93
  h3 {
88
- font-size: 20px;
94
+ font-size: 16px;
89
95
  /*21 / 16*/
90
96
  line-height: 1.15;
91
97
  /*24 / 21*/
package/styles/yellow.css CHANGED
@@ -72,20 +72,26 @@ h1 {
72
72
  }
73
73
 
74
74
  h2{
75
- font-size: 25px;
76
- padding: 10px 10px 10px 10px; /* 上、右、下、左的内边距分别为10px、20px、15px、25px */
77
- line-height: 1.15;
75
+ display: block;
76
+ width: 100%;
77
+ font-size: 18px;
78
+ font-weight: 800;
79
+ padding: 8px 14px;
80
+ line-height: 1.4;
78
81
  /*24 / 21*/
79
82
  margin-top: 1.85em;
80
83
  /*48 / 21*/
81
84
  margin-bottom: 1.15em;
82
85
  /*24 / 21*/
83
- background:#FFD139;
84
- color:#fff;
86
+ margin-left: 0;
87
+ border-bottom: none;
88
+ box-sizing: border-box;
89
+ background:#FFD139;
90
+ color:#fff;
85
91
  }
86
92
 
87
93
  h3 {
88
- font-size: 20px;
94
+ font-size: 16px;
89
95
  /*21 / 16*/
90
96
  line-height: 1.15;
91
97
  /*24 / 21*/