Skill: zhylq/zhy-markdown2wechat (version 0.1.0)

--- name: zhy-markdown2wechat description: Use when converting Markdown into WeChat-compatible inline HTML with theme styles for preview, copy-paste, or downstream draft publishing. --- ## 概述 这是一个用于将标准的 Markdown 文本，转换成能够直接复制粘贴给微信公众号文章编辑器的 HTML 文件的 Skill。微信公众号的 HTML 结构要求所有样式必须是内联的（Inline CSS）。 此 Skill 的核心优势是 **零部署**。只要用户的环境中安装了 Node.js，即可通过执行本 Skill 自带的转换脚本极其轻量地完成转换任务，它会自动在临时目录加载所需依赖并在完成后清理，不留任何环境垃圾，无需用户预先执行 `npm install`。 ## 适用场景 当用户希望你： - 把 md、markdown 格式的文件转为微信公众号文章。 - 根据 Markdown 生成带 CSS 样式的公众号排版 HTML。 ## 详细执行步骤 当你收到用户的转换请求时，如果不指定主题，默认使用 `resources/themes/default.css`。 请你**直接**代用户执行以下命令，调用本 Skill 自带的 `scripts/convert.js`。如果你在使用工具（例如 Terminal / run_command），请直接调用即可。 ### 执行转换脚本 使用 `node` 执行转换： ```bash node <当前skill路径>/scripts/convert.js <用户指定的markdown文件> <选择的主题css文件> <输出目标html文件路径> ``` *(例如将 `input.md` 转换为带默认主题的 `output.html`：`node wechat-markdown-skill/scripts/convert.js input.md wechat-markdown-skill/resources/themes/default.css output.html`)* 脚本将会自动安全地处理 Markdown 转换、增加 `<section id="MdWechat">` 微信容器、内联注入指定的 CSS 主题。 注意：当前主题体系会在容器根节点中携带 CSS 变量（如 `--text-color`），以便多主题共享配色语义。若后续要通过 `zhy-wechat-publish` 上传到草稿箱，应使用其最新发布脚本，它会在上传前自动展开 `var(--xxx)`，避免微信后台丢失颜色样式。 ### 交付输出结果 完成后，直接告诉用户："您的公众号 HTML 已生成在 `[目标文件]` 中，可直接在浏览器打开预览效果，或用编辑器/浏览器打开后全选复制，粘贴到微信公众号后台即可。" ## 主题支持 (Themes) 本目录下的 `resources/themes/` 可以存放多套不同的 CSS 主题方案。 如果用户要求更换主题风格，你可以查看并读取该目录下存在的 CSS 文件路径并传递给脚本，这使得该 Skill 天然支持“换肤”功能。

path: README.md
content: # zhy-markdown2wechat

辅助 skill：将 Markdown 转换为微信公众号可用的内联 HTML，并支持主题样式。

## Install

```bash
npx skills add https://github.com/zhylq/yuan-skills --skill zhy-markdown2wechat
```

## What It Does

- 读取 Markdown 文件
- 读取主题 CSS
- 转换为 HTML
- 输出根容器为 `<section id="MdWechat">` 的微信风格 HTML

## Environment

本 skill 不需要 `.env`。

## Usage Notes

- 主题文件位于 `resources/themes/`
- 当前支持：`default.css`、`apple.css`、`blue.css`、`dark.css`、`green.css`、`notion.css`、`vibrant.css`
- 若后续要配合 `zhy-wechat-publish` 上传草稿箱，推荐先用本 skill 生成 HTML，再交给发布 skill 处理 CSS 变量、图片和列表兼容

## Output

- 输出 HTML 文件，例如 `article.zhy.html`

## Limitations

- 当前脚本会在临时目录安装运行所需依赖
- 它更适合作为 skill 内部转换步骤，而不是通用生产级 npm CLI


path: resources/themes/apple.css
content: /* 方案一：Apple Tech (苹果极简科技风) */
/* 极度的克制留白、原生高级系统字体感、红绿灯代码块设计 */

:root {
    --app-bg: #FFFFFF;
    --text-main: #333333;
    --text-mutated: #86868b;
    --accent: #0071E3;
    --bg-quote: #F5F5F7;
    --bg-code: #1d1d1f;
    --border-radius-lg: 12px;
    --font-sys: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#MdWechat {
    line-height: 1.8;
    color: #333333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: 0.5px;
    background: #FFFFFF;
    padding: 10px 5px;
    font-size: 15px;
}

/* 基础段落 */
#MdWechat p {
    color: #333333;
    margin: 1.2em 0;
    line-height: 1.8;
    font-size: 15px;
    font-weight: 400;
}

/* 一级标题：极简大字重，仅靠留白隔离 */
#MdWechat h1 {
    font-size: 26px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 1.8em 0 0.8em 0;
    letter-spacing: -0.5px;
}

#MdWechat h1 .content {
    display: block;
}

/* 二级标题：稍小的字号，无边框，极度干净 */
#MdWechat h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 1.6em 0 0.8em 0;
    letter-spacing: -0.3px;
}

#MdWechat h2 .content {
    display: block;
}

/* 三级标题 */
#MdWechat h3 {
    font-size: 17px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 1.4em 0 0.6em 0;
}

/* 列表 */
#MdWechat ul,
#MdWechat ol {
    font-size: 15px;
    color: #333333;
    padding-left: 20px;
    margin: 1em 0;
}

#MdWechat li {
    margin: 0.5em 0;
    line-height: 1.7;
}

#MdWechat li section {
    font-size: 15px;
    color: #333333;
}

/* 重点设计：引用块 (Blockquote) */
/* 取消左侧竖线，使用大块浅灰色背景，模拟官网 Note 卡片 */
#MdWechat blockquote {
    background: #F5F5F7;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 1.5em 0;
    border: none;
    border-left: 0px solid transparent;
}

#MdWechat blockquote p {
    color: #424245;
    margin: 0;
    font-size: 14.5px;
    line-height: 1.6;
}

/* 粗体字与高亮字 */
#MdWechat strong {
    font-weight: 600;
    color: #1d1d1f;
}

#MdWechat em {
    font-style: italic;
    color: #86868b;
    background: transparent;
}

/* 链接 */
#MdWechat a {
    color: #0071E3;
    text-decoration: none;
    font-weight: 400;
}

/* 行内代码 */
#MdWechat p code,
#MdWechat li code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13.5px;
    color: #eb4d4b;
    background: rgba(245, 245, 247, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
}

/* 重点设计：高级代码块 (MacOS Terminal 风格) */
/* 微信对伪元素兼容一般，为了稳定代码块本体背景和顶部内边距 */
#MdWechat pre {
    background: #1d1d1f;
    border-radius: 12px;
    padding: 38px 16px 16px 16px;
    margin: 1.5em 0;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    position: relative;
    /* 模拟 MacOS 窗口的三颗红绿灯按钮 */
    /* 在微信某些环境中可能会被吃掉，但作为降级方案，仅提供纯黑圆角背景也足够高级 */
    background-image:
        radial-gradient(circle at 18px 20px, #ff5f56 5px, transparent 5.5px),
        radial-gradient(circle at 36px 20px, #ffbd2e 5px, transparent 5.5px),
        radial-gradient(circle at 54px 20px, #27c93f 5px, transparent 5.5px);
    background-repeat: no-repeat;
}

#MdWechat pre code {
    color: #f5f5f7;
    background: transparent;
    padding: 0;
    font-family: inherit;
}

/* 特殊代码块修复 */
#MdWechat .code-snippet__fix {
    background: #1d1d1f;
    border-radius: 12px;
}

/* 分隔线 */
#MdWechat hr {
    height: 1px;
    border: none;
    background-color: #d2d2d7;
    margin: 2em auto;
    width: 60%;
}

/* 图片 */
#MdWechat img {
    border-radius: 12px;
    max-width: 100%;
    margin: 1.5em auto;
    display: block;
}

#MdWechat figcaption {
    text-align: center;
    font-size: 12px;
    color: #86868b;
    margin-top: -1em;
    margin-bottom: 1.5em;
}

/* 表格 */
#MdWechat table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
}

#MdWechat table tr th {
    background: #F5F5F7;
    color: #1d1d1f;
    font-weight: 600;
    padding: 10px;
    border: 1px solid #d2d2d7;
}

#MdWechat table tr td {
    padding: 10px;
    color: #333333;
    border: 1px solid #d2d2d7;
}

path: resources/themes/blue.css
content: /* Blue theme - polished editorial tech */

:root {
  --primary-color: #1976d2;
  --secondary-color: #8ec5ff;
  --background-color: #eaf4ff;
  --link-color: #1459a8;
  --text-color: #3b4b57;
  --border-color: #b8dafc;
  --hr-color: #7dbaf5;
  --code-bg: #17304f;
  --code-text: #c9e4ff;
  --inline-code-bg: rgba(25, 118, 210, 0.10);
}

#MdWechat {
  padding: 0 10px;
  background-color: transparent;
  background-image: linear-gradient(90deg, rgba(18, 79, 142, 0.05) 0%, rgba(0, 0, 0, 0) 6.76%), linear-gradient(360deg, rgba(18, 79, 142, 0.05) 0%, rgba(234, 244, 255, 0) 9.46%);
  background-repeat: repeat, repeat;
  background-size: 20px 20px, 20px 20px;
  background-position: left top, left top;
  color: var(--text-color);
  font-family: Optima, "Microsoft YaHei", PingFangSC-Regular, serif;
  font-size: 16px;
  line-height: 1.5em;
  letter-spacing: 0;
  word-spacing: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

#MdWechat h1,
#MdWechat h2,
#MdWechat h3,
#MdWechat h4,
#MdWechat h5,
#MdWechat h6 {
  margin-left: 0;
  margin-right: 0;
  padding: 0;
}

#MdWechat h1 {
  display: block;
  margin: 30px 0 15px;
}

#MdWechat h1,
#MdWechat h1 .content {
  font-size: 24px;
  color: var(--text-color);
  line-height: 1.5em;
  letter-spacing: 0;
  text-align: left;
  font-weight: 700;
}

#MdWechat h1 .content {
  display: block;
}

#MdWechat h2 {
  display: block;
  margin: 30px 0 15px;
  text-align: left;
}

#MdWechat h2,
#MdWechat h2 .content {
  color: var(--text-color);
}

#MdWechat h2 .content,
#MdWechat h2:not(:has(.content)) {
  display: block;
  font-size: 18px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 700;
  padding-left: 10px;
  border-left: 5px solid var(--secondary-color);
}

#MdWechat h3 {
  display: block;
  margin: 30px 0 15px;
  text-align: center;
}

#MdWechat h3,
#MdWechat h3 .content {
  color: var(--text-color);
}

#MdWechat h3 .content,
#MdWechat h3:not(:has(.content)) {
  font-size: 17px;
  line-height: 1.5em;
  letter-spacing: 0;
  font-weight: 700;
  border-bottom: 2px solid var(--secondary-color);
}

#MdWechat h3 .content {
  display: inline-block;
}

#MdWechat h3:not(:has(.content)) {
  display: table;
  margin: 30px auto 15px;
}

#MdWechat h4,
#MdWechat h4 .content {
  margin: 24px 0 12px;
  font-size: 16px;
  line-height: 1.6em;
  color: var(--text-color);
  font-weight: 700;
}

#MdWechat p {
  color: var(--text-color);
  font-size: 15px;
  line-height: 1.8em;
  letter-spacing: 0.02em;
  text-align: left;
  text-indent: 0;
  margin: 0;
  padding: 8px 0;
}

#MdWechat ul,
#MdWechat ol {
  margin: 8px 0;
  padding: 0 0 0 25px;
  color: #000;
}

#MdWechat ul {
  list-style-type: circle;
}

#MdWechat ol {
  list-style-type: decimal;
}

#MdWechat li,
#MdWechat li section,
#MdWechat li p {
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 400;
}

#MdWechat li section,
#MdWechat li p {
  margin: 5px 0;
  padding: 0;
}

#MdWechat blockquote {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--background-color);
  color: var(--text-color);
}

#MdWechat blockquote::before {
  content: "❝";
  color: var(--secondary-color);
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

#MdWechat blockquote::after {
  content: "❞";
  float: right;
  color: var(--secondary-color);
}

#MdWechat blockquote p {
  color: var(--text-color);
}

#MdWechat a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid var(--link-color);
}

#MdWechat strong {
  color: var(--primary-color);
  font-weight: 700;
}

#MdWechat em {
  font-style: normal;
  color: var(--primary-color);
  background: linear-gradient(transparent 65%, var(--background-color) 35%);
}

#MdWechat del {
  color: #6f8190;
}

#MdWechat hr {
  height: 0;
  margin: 24px 0;
  border: none;
  border-top: 2px solid var(--hr-color);
}

#MdWechat img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin: 20px auto;
  object-fit: contain;
}

#MdWechat figcaption {
  display: block;
  color: var(--text-color);
  font-size: 13px;
  text-align: center;
}

#MdWechat p code,
#MdWechat li code,
#MdWechat td code,
#MdWechat th code {
  color: var(--primary-color);
  background: var(--inline-code-bg);
  margin: 0 2px;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;
  word-break: break-all;
}

#MdWechat .code-snippet__fix {
  background: #eef5fb;
  border-radius: 2px;
}

#MdWechat pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 15px;
  overflow-x: auto;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
}

#MdWechat pre code {
  color: var(--code-text);
  background: transparent;
  margin: 0;
  padding: 0;
}

#MdWechat table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

#MdWechat table tr th,
#MdWechat table tr td {
  font-size: 14px;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
}

#MdWechat table tr th {
  background: rgba(142, 197, 255, 0.18);
  font-weight: 700;
}

#MdWechat .footnotes {
  background: var(--background-color);
  padding: 20px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

#MdWechat .footnote-word,
#MdWechat .footnote-ref,
#MdWechat .footnote-item p,
#MdWechat .footnote-item em {
  color: var(--text-color);
}

#MdWechat .footnote-item p {
  font-weight: 700;
}

#MdWechat .footnote-item em {
  display: block;
  background: transparent;
  font-weight: 400;
  font-size: 14px;
}

#MdWechat .footnotes-sep:before {
  content: "Reference";
  display: inline;
  color: var(--text-color);
  font-size: 20px;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--secondary-color);
  background: linear-gradient(white 60%, var(--background-color) 40%);
}

#MdWechat .imageflow-img {
  display: inline-block;
  width: 100%;
  margin-bottom: 0;
}


path: resources/themes/dark.css
content: /* Dark theme - editorial night mode */

:root {
  --primary-color: #78b7ff;
  --secondary-color: #4da3ff;
  --background-color: #1a222d;
  --link-color: #8bc2ff;
  --text-color: #d6deea;
  --border-color: #2f3b4d;
  --hr-color: #2a3443;
  --code-bg: #0f141b;
  --code-text: #dbeafe;
  --inline-code-bg: rgba(120, 183, 255, 0.16);
}

#MdWechat {
  padding: 0 10px;
  background: #131922;
  color: var(--text-color);
  font-family: Optima, "Microsoft YaHei", PingFangSC-Regular, serif;
  font-size: 16px;
  line-height: 1.5em;
  letter-spacing: 0;
  word-spacing: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

#MdWechat h1,
#MdWechat h2,
#MdWechat h3,
#MdWechat h4,
#MdWechat h5,
#MdWechat h6 {
  margin-left: 0;
  margin-right: 0;
  padding: 0;
}

#MdWechat h1 {
  display: block;
  margin: 30px 0 15px;
}

#MdWechat h1,
#MdWechat h1 .content {
  font-size: 24px;
  color: #f3f7fb;
  line-height: 1.5em;
  letter-spacing: 0;
  text-align: left;
  font-weight: 700;
}

#MdWechat h1 .content {
  display: block;
}

#MdWechat h2 {
  display: block;
  margin: 30px 0 15px;
  text-align: left;
}

#MdWechat h2,
#MdWechat h2 .content {
  color: #eef4fb;
}

#MdWechat h2 .content,
#MdWechat h2:not(:has(.content)) {
  display: block;
  font-size: 18px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 700;
  padding-left: 10px;
  border-left: 5px solid var(--secondary-color);
}

#MdWechat h3 {
  display: block;
  margin: 30px 0 15px;
  text-align: center;
}

#MdWechat h3,
#MdWechat h3 .content {
  color: #e6eef8;
}

#MdWechat h3 .content,
#MdWechat h3:not(:has(.content)) {
  font-size: 17px;
  line-height: 1.5em;
  letter-spacing: 0;
  font-weight: 700;
  border-bottom: 2px solid var(--secondary-color);
}

#MdWechat h3 .content {
  display: inline-block;
}

#MdWechat h3:not(:has(.content)) {
  display: table;
  margin: 30px auto 15px;
}

#MdWechat h4,
#MdWechat h4 .content {
  margin: 24px 0 12px;
  font-size: 16px;
  line-height: 1.6em;
  color: #e6eef8;
  font-weight: 700;
}

#MdWechat p {
  color: var(--text-color);
  font-size: 15px;
  line-height: 1.8em;
  letter-spacing: 0.02em;
  text-align: left;
  text-indent: 0;
  margin: 0;
  padding: 8px 0;
}

#MdWechat ul,
#MdWechat ol {
  margin: 8px 0;
  padding: 0 0 0 25px;
  color: #f4f7fb;
}

#MdWechat ul {
  list-style-type: circle;
}

#MdWechat ol {
  list-style-type: decimal;
}

#MdWechat li,
#MdWechat li section,
#MdWechat li p {
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 400;
}

#MdWechat li section,
#MdWechat li p {
  margin: 5px 0;
  padding: 0;
}

#MdWechat blockquote {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--background-color);
  color: var(--text-color);
}

#MdWechat blockquote::before {
  content: "❝";
  color: var(--secondary-color);
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

#MdWechat blockquote::after {
  content: "❞";
  float: right;
  color: var(--secondary-color);
}

#MdWechat blockquote p {
  color: var(--text-color);
}

#MdWechat a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid var(--link-color);
}

#MdWechat strong {
  color: #f6fbff;
  font-weight: 700;
  background: rgba(77, 163, 255, 0.18);
  padding: 0 4px;
  border-radius: 4px;
}

#MdWechat em {
  font-style: normal;
  color: #dff0ff;
  background: linear-gradient(transparent 65%, rgba(77, 163, 255, 0.20) 35%);
}

#MdWechat del {
  color: #8793a2;
}

#MdWechat hr {
  height: 0;
  margin: 24px 0;
  border: none;
  border-top: 2px solid var(--hr-color);
}

#MdWechat img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin: 20px auto;
  object-fit: contain;
  border: 1px solid var(--border-color);
}

#MdWechat figcaption {
  display: block;
  color: #a8b6c7;
  font-size: 13px;
  text-align: center;
}

#MdWechat p code,
#MdWechat li code,
#MdWechat td code,
#MdWechat th code {
  color: #e8f4ff;
  background: var(--inline-code-bg);
  margin: 0 2px;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;
  word-break: break-all;
}

#MdWechat .code-snippet__fix {
  background: #161d27;
  border-radius: 2px;
  border: 1px solid var(--border-color);
}

#MdWechat pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 15px;
  overflow-x: auto;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border-color);
}

#MdWechat pre code {
  color: var(--code-text);
  background: transparent;
  margin: 0;
  padding: 0;
}

#MdWechat table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

#MdWechat table tr th,
#MdWechat table tr td {
  font-size: 14px;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
}

#MdWechat table tr th {
  background: rgba(77, 163, 255, 0.16);
  font-weight: 700;
  color: #eef4fb;
}

#MdWechat .footnotes {
  background: var(--background-color);
  padding: 20px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

#MdWechat .footnote-word,
#MdWechat .footnote-ref,
#MdWechat .footnote-item p,
#MdWechat .footnote-item em {
  color: var(--text-color);
}

#MdWechat .footnote-item p {
  font-weight: 700;
}

#MdWechat .footnote-item em {
  display: block;
  background: transparent;
  font-weight: 400;
  font-size: 14px;
}

#MdWechat .footnotes-sep:before {
  content: "Reference";
  display: inline;
  color: #eef4fb;
  font-size: 20px;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--secondary-color);
  background: linear-gradient(#131922 60%, var(--background-color) 40%);
}

#MdWechat .imageflow-img {
  display: inline-block;
  width: 100%;
  margin-bottom: 0;
}


path: resources/themes/default.css
content: /* Default theme - refined editorial purple */

:root {
  --primary-color: #916dd5;
  --secondary-color: #dec6fb;
  --background-color: #f6eeff;
  --link-color: #664d9d;
  --text-color: #595959;
  --border-color: #dec6fb;
  --hr-color: #d9b8fa;
  --code-bg: #282c34;
  --code-text: #abb2bf;
  --inline-code-bg: rgba(27, 31, 35, 0.05);
}

#MdWechat {
  padding: 0 10px;
  background-color: transparent;
  background-image: linear-gradient(90deg, rgba(50, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0) 6.76%), linear-gradient(360deg, rgba(50, 0, 0, 0.05) 0%, rgba(249, 247, 252, 0) 9.46%);
  background-repeat: repeat, repeat;
  background-size: 20px 20px, 20px 20px;
  background-position: left top, left top;
  color: var(--text-color);
  font-family: Optima, "Microsoft YaHei", PingFangSC-Regular, serif;
  font-size: 16px;
  line-height: 1.5em;
  letter-spacing: 0;
  word-spacing: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

#MdWechat h1,
#MdWechat h2,
#MdWechat h3,
#MdWechat h4,
#MdWechat h5,
#MdWechat h6 {
  margin-left: 0;
  margin-right: 0;
  padding: 0;
}

#MdWechat h1 {
  display: block;
  margin: 30px 0 15px;
}

#MdWechat h1,
#MdWechat h1 .content {
  font-size: 24px;
  color: var(--text-color);
  line-height: 1.5em;
  letter-spacing: 0;
  text-align: left;
  font-weight: 700;
}

#MdWechat h1 .content {
  display: block;
}

#MdWechat h2 {
  display: block;
  margin: 30px 0 15px;
  text-align: left;
}

#MdWechat h2,
#MdWechat h2 .content {
  color: var(--text-color);
}

#MdWechat h2 .content,
#MdWechat h2:not(:has(.content)) {
  display: block;
  font-size: 18px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 700;
  padding-left: 10px;
  border-left: 5px solid var(--secondary-color);
}

#MdWechat h3 {
  display: block;
  margin: 30px 0 15px;
  text-align: center;
}

#MdWechat h3,
#MdWechat h3 .content {
  color: var(--text-color);
}

#MdWechat h3 .content,
#MdWechat h3:not(:has(.content)) {
  font-size: 17px;
  line-height: 1.5em;
  letter-spacing: 0;
  font-weight: 700;
  border-bottom: 2px solid var(--secondary-color);
}

#MdWechat h3 .content {
  display: inline-block;
}

#MdWechat h3:not(:has(.content)) {
  display: table;
  margin: 30px auto 15px;
}

#MdWechat h4,
#MdWechat h4 .content {
  margin: 24px 0 12px;
  font-size: 16px;
  line-height: 1.6em;
  color: var(--text-color);
  font-weight: 700;
}

#MdWechat p {
  color: var(--text-color);
  font-size: 15px;
  line-height: 1.8em;
  letter-spacing: 0.02em;
  text-align: left;
  text-indent: 0;
  margin: 0;
  padding: 8px 0;
}

#MdWechat ul,
#MdWechat ol {
  margin: 8px 0;
  padding: 0 0 0 25px;
  color: #000;
}

#MdWechat ul {
  list-style-type: circle;
}

#MdWechat ol {
  list-style-type: decimal;
}

#MdWechat li {
  margin: 0;
  padding: 0;
}

#MdWechat li,
#MdWechat li section,
#MdWechat li p {
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.8em;
  letter-spacing: 0;
  text-align: left;
  font-weight: 400;
}

#MdWechat li section,
#MdWechat li p {
  margin: 5px 0;
  padding: 0;
}

#MdWechat blockquote {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--background-color);
  color: var(--text-color);
}

#MdWechat blockquote::before {
  content: "❝";
  color: var(--secondary-color);
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

#MdWechat blockquote::after {
  content: "❞";
  float: right;
  color: var(--secondary-color);
}

#MdWechat blockquote p {
  color: var(--text-color);
}

#MdWechat a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid var(--link-color);
}

#MdWechat strong {
  color: var(--primary-color);
  font-weight: 700;
}

#MdWechat em {
  font-style: normal;
  color: var(--primary-color);
  background: linear-gradient(transparent 65%, var(--background-color) 35%);
}

#MdWechat del {
  color: #777;
}

#MdWechat hr {
  height: 0;
  margin: 24px 0;
  border: none;
  border-top: 2px solid var(--hr-color);
}

#MdWechat img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin: 20px auto;
  object-fit: contain;
}

#MdWechat figcaption {
  display: block;
  color: var(--text-color);
  font-size: 13px;
  text-align: center;
}

#MdWechat p code,
#MdWechat li code,
#MdWechat td code,
#MdWechat th code {
  color: var(--primary-color);
  background: var(--inline-code-bg);
  margin: 0 2px;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;
  word-break: break-all;
}

#MdWechat .code-snippet__fix {
  background: #f7f7f7;
  border-radius: 2px;
}

#MdWechat pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 15px;
  overflow-x: auto;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
}

#MdWechat pre code {
  color: var(--code-text);
  background: transparent;
  margin: 0;
  padding: 0;
}

#MdWechat table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

#MdWechat table tr th,
#MdWechat table tr td {
  font-size: 14px;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
}

#MdWechat table tr th {
  background: rgba(222, 198, 251, 0.22);
  font-weight: 700;
}

#MdWechat .footnotes {
  background: var(--background-color);
  padding: 20px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

#MdWechat .footnote-word,
#MdWechat .footnote-ref,
#MdWechat .footnote-item p,
#MdWechat .footnote-item em {
  color: var(--text-color);
}

#MdWechat .footnote-item p {
  font-weight: 700;
}

#MdWechat .footnote-item em {
  display: block;
  background: transparent;
  font-weight: 400;
  font-size: 14px;
}

#MdWechat .footnotes-sep:before {
  content: "Reference";
  display: inline;
  color: var(--text-color);
  font-size: 20px;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--secondary-color);
  background: linear-gradient(white 60%, var(--background-color) 40%);
}

#MdWechat .imageflow-img {
  display: inline-block;
  width: 100%;
  margin-bottom: 0;
}


path: resources/themes/green.css
content: /* Green theme - calm editorial botanical */

:root {
  --primary-color: #2f8f5b;
  --secondary-color: #9ad8b7;
  --background-color: #edf8f1;
  --link-color: #2a6f4f;
  --text-color: #40504a;
  --border-color: #bfe7cf;
  --hr-color: #7bc799;
  --code-bg: #24332e;
  --code-text: #c2efd3;
  --inline-code-bg: rgba(47, 143, 91, 0.10);
}

#MdWechat {
  padding: 0 10px;
  background-color: transparent;
  background-image: linear-gradient(90deg, rgba(24, 86, 54, 0.05) 0%, rgba(0, 0, 0, 0) 6.76%), linear-gradient(360deg, rgba(24, 86, 54, 0.05) 0%, rgba(237, 248, 241, 0) 9.46%);
  background-repeat: repeat, repeat;
  background-size: 20px 20px, 20px 20px;
  background-position: left top, left top;
  color: var(--text-color);
  font-family: Optima, "Microsoft YaHei", PingFangSC-Regular, serif;
  font-size: 16px;
  line-height: 1.5em;
  letter-spacing: 0;
  word-spacing: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

#MdWechat h1,
#MdWechat h2,
#MdWechat h3,
#MdWechat h4,
#MdWechat h5,
#MdWechat h6 {
  margin-left: 0;
  margin-right: 0;
  padding: 0;
}

#MdWechat h1 {
  display: block;
  margin: 30px 0 15px;
}

#MdWechat h1,
#MdWechat h1 .content {
  font-size: 24px;
  color: var(--text-color);
  line-height: 1.5em;
  letter-spacing: 0;
  text-align: left;
  font-weight: 700;
}

#MdWechat h1 .content {
  display: block;
}

#MdWechat h2 {
  display: block;
  margin: 30px 0 15px;
  text-align: left;
}

#MdWechat h2,
#MdWechat h2 .content {
  color: var(--text-color);
}

#MdWechat h2 .content,
#MdWechat h2:not(:has(.content)) {
  display: block;
  font-size: 18px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 700;
  padding-left: 10px;
  border-left: 5px solid var(--secondary-color);
}

#MdWechat h3 {
  display: block;
  margin: 30px 0 15px;
  text-align: center;
}

#MdWechat h3,
#MdWechat h3 .content {
  color: var(--text-color);
}

#MdWechat h3 .content,
#MdWechat h3:not(:has(.content)) {
  font-size: 17px;
  line-height: 1.5em;
  letter-spacing: 0;
  font-weight: 700;
  border-bottom: 2px solid var(--secondary-color);
}

#MdWechat h3 .content {
  display: inline-block;
}

#MdWechat h3:not(:has(.content)) {
  display: table;
  margin: 30px auto 15px;
}

#MdWechat h4,
#MdWechat h4 .content {
  margin: 24px 0 12px;
  font-size: 16px;
  line-height: 1.6em;
  color: var(--text-color);
  font-weight: 700;
}

#MdWechat p {
  color: var(--text-color);
  font-size: 15px;
  line-height: 1.8em;
  letter-spacing: 0.02em;
  text-align: left;
  text-indent: 0;
  margin: 0;
  padding: 8px 0;
}

#MdWechat ul,
#MdWechat ol {
  margin: 8px 0;
  padding: 0 0 0 25px;
  color: #000;
}

#MdWechat ul {
  list-style-type: circle;
}

#MdWechat ol {
  list-style-type: decimal;
}

#MdWechat li,
#MdWechat li section,
#MdWechat li p {
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.8em;
  letter-spacing: 0;
  font-weight: 400;
}

#MdWechat li section,
#MdWechat li p {
  margin: 5px 0;
  padding: 0;
}

#MdWechat blockquote {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--background-color);
  color: var(--text-color);
}

#MdWechat blockquote::before {
  content: "❝";
  color: var(--secondary-color);
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

#MdWechat blockquote::after {
  content: "❞";
  float: right;
  color: var(--secondary-color);
}

#MdWechat blockquote p {
  color: var(--text-color);
}

#MdWechat a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid var(--link-color);
}

#MdWechat strong {
  color: var(--primary-color);
  font-weight: 700;
}

#MdWechat em {
  font-style: normal;
  color: var(--primary-color);
  background: linear-gradient(transparent 65%, var(--background-color) 35%);
}

#MdWechat del {
  color: #6c7f76;
}

#MdWechat hr {
  height: 0;
  margin: 24px 0;
  border: none;
  border-top: 2px solid var(--hr-color);
}

#MdWechat img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin: 20px auto;
  object-fit: contain;
}

#MdWechat figcaption {
  display: block;
  color: var(--text-color);
  font-size: 13px;
  text-align: center;
}

#MdWechat p code,
#MdWechat li code,
#MdWechat td code,
#MdWechat th code {
  color: var(--primary-color);
  background: var(--inline-code-bg);
  margin: 0 2px;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;
  word-break: break-all;
}

#MdWechat .code-snippet__fix {
  background: #f3f8f5;
  border-radius: 2px;
}

#MdWechat pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 15px;
  overflow-x: auto;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
}

#MdWechat pre code {
  color: var(--code-text);
  background: transparent;
  margin: 0;
  padding: 0;
}

#MdWechat table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

#MdWechat table tr th,
#MdWechat table tr td {
  font-size: 14px;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
}

#MdWechat table tr th {
  background: rgba(154, 216, 183, 0.20);
  font-weight: 700;
}

#MdWechat .footnotes {
  background: var(--background-color);
  padding: 20px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

#MdWechat .footnote-word,
#MdWechat .footnote-ref,
#MdWechat .footnote-item p,
#MdWechat .footnote-item em {
  color: var(--text-color);
}

#MdWechat .footnote-item p {
  font-weight: 700;
}

#MdWechat .footnote-item em {
  display: block;
  background: transparent;
  font-weight: 400;
  font-size: 14px;
}

#MdWechat .footnotes-sep:before {
  content: "Reference";
  display: inline;
  color: var(--text-color);
  font-size: 20px;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--secondary-color);
  background: linear-gradient(white 60%, var(--background-color) 40%);
}

#MdWechat .imageflow-img {
  display: inline-block;
  width: 100%;
  margin-bottom: 0;
}


path: resources/themes/notion.css
content: /* 方案二：Notion Elegance (Notion 优雅手帐风) */
/* 沉静温婉、米黄背景、左段落线强调设计 */

:root {
    --bg-main: #FFFCF8;
    --text-main: #37352F;
    --text-gray: #9B9A97;
    --accent-orange: #D9730D;
    --accent-green: #0F7B6C;
    --bg-quote: #F7F6F3;
    --highlight: rgba(255, 212, 0, 0.4);
}

#MdWechat {
    line-height: 1.7;
    color: #37352F;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
    background: #FFFCF8;
    padding: 15px 10px;
    font-size: 16px;
}

/* 基础段落 */
#MdWechat p {
    color: #37352F;
    margin: 0.8em 0;
    line-height: 1.7;
}

/* 一级标题：沉稳无修饰大字 */
#MdWechat h1 {
    font-size: 30px;
    font-weight: 700;
    color: #37352F;
    margin: 1.2em 0 0.5em 0;
}

#MdWechat h1 .content {
    display: block;
}

/* 二级标题：底部自带马克笔高光下划线 */
#MdWechat h2 {
    font-size: 24px;
    font-weight: 700;
    color: #37352F;
    margin: 1.5em 0 0.5em 0;
    position: relative;
}

#MdWechat h2 .content {
    display: inline-block;
    background: linear-gradient(180deg, transparent 65%, rgba(255, 212, 0, 0.4) 65%);
    padding: 0 4px;
}

/* 三级标题 */
#MdWechat h3 {
    font-size: 20px;
    font-weight: 600;
    color: #37352F;
    margin: 1.2em 0 0.5em 0;
}

/* 列表缩进加大，Notion 特色 */
#MdWechat ul,
#MdWechat ol {
    color: #37352F;
    padding-left: 28px;
    margin: 0.8em 0;
}

#MdWechat li {
    margin: 0.3em 0;
}

#MdWechat li section {
    color: #37352F;
}

/* 重点设计：引用块 (Blockquote) - Notion 经典左线 */
#MdWechat blockquote {
    background: transparent;
    padding: 2px 2px 2px 14px;
    margin: 1.2em 0;
    border-left: 3px solid #37352F;
    border-top: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
}

#MdWechat blockquote p {
    color: #37352F;
    font-size: 16px;
    font-style: normal;
}

/* 强调文字 */
#MdWechat strong {
    font-weight: 600;
    color: #37352F;
}

#MdWechat em {
    font-style: italic;
    color: #9B9A97;
    background: transparent;
}

/* 链接色 */
#MdWechat a {
    color: #9B9A97;
    text-decoration: none;
    border-bottom: 1px solid rgba(155, 154, 151, 0.4);
}

/* 行内代码：浅色底加橘红字 */
#MdWechat p code,
#MdWechat li code {
    color: #EB5757;
    background: rgba(135, 131, 120, 0.15);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 85%;
}

/* 重点设计：优雅的浅灰色代码块容器 */
#MdWechat pre {
    background: #F7F6F3;
    border-radius: 4px;
    padding: 16px 20px;
    margin: 1.2em 0;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, Menlo, Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid rgba(223, 225, 228, 0.5);
}

#MdWechat pre code {
    color: #37352F;
    background: transparent;
    padding: 0;
}

#MdWechat .code-snippet__fix {
    background: #F7F6F3;
    border-radius: 4px;
}

/* 分隔线：点状线 */
#MdWechat hr {
    height: 0;
    border: none;
    border-top: 1px dashed rgba(55, 53, 47, 0.16);
    margin: 2em 0;
}

/* 图片 */
#MdWechat img {
    border-radius: 4px;
    max-width: 100%;
    margin: 1.2em auto;
    display: block;
}

#MdWechat figcaption {
    text-align: center;
    font-size: 13px;
    color: rgba(55, 53, 47, 0.6);
    margin-top: -0.5em;
}

/* 表格 */
#MdWechat table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
}

#MdWechat table tr th {
    background: #F7F6F3;
    color: #37352F;
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(55, 53, 47, 0.16);
}

#MdWechat table tr td {
    padding: 8px 12px;
    color: #37352F;
    border-bottom: 1px solid rgba(55, 53, 47, 0.09);
}

path: resources/themes/vibrant.css
content: /* 方案三：Vibrant Glassmorphism (毛玻璃高亮现代风) */
/* 炫彩渐变、圆角容器、悬浮阴影感设计 */

:root {
    --app-bg: #FAFAFB;
    --text-main: #334155;
    --text-light: #64748B;
    --accent-base: #7C3AED;
    --accent-gradient: linear-gradient(135deg, #7C3AED, #3B82F6);
    --bg-quote: #F3F4F6;
    --bg-card: #FFFFFF;
    --shadow-sm: 0 4px 6px -1px rgba(124, 58, 237, 0.05), 0 2px 4px -1px rgba(124, 58, 237, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(124, 58, 237, 0.1), 0 4px 6px -2px rgba(124, 58, 237, 0.05);
    --border-radius-xl: 16px;
}

#MdWechat {
    line-height: 1.8;
    color: #334155;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.5px;
    background: #FAFAFB;
    padding: 16px 10px;
    font-size: 15px;
}

/* 基础段落 */
#MdWechat p {
    color: #334155;
    margin: 1.2em 0;
    line-height: 1.8;
}

/* 一级标题：炫彩渐变文字（微信支持部分 Webkit 属性） */
#MdWechat h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 1.6em 0 1em 0;
    text-align: center;
}

#MdWechat h1 .content {
    display: inline-block;
    background: linear-gradient(135deg, #7C3AED, #3B82F6);
    -webkit-background-clip: text;
    color: #7C3AED;
    /* Fallback for WeChat */
    margin-bottom: 4px;
}

/* 二级标题：带紫色渐变块作为强调符号 */
#MdWechat h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1E293B;
    margin: 2em 0 1em 0;
    display: flex;
    align-items: center;
}

#MdWechat h2 .content {
    border-left: none;
    padding-left: 0;
}

/* 微信内联可能不支持伪元素直接展示色彩渐变块，我们使用左侧实心边框加圆角模拟 */
#MdWechat h2 {
    border-left: 6px solid #7C3AED;
    padding-left: 12px;
    border-radius: 4px;
}

/* 三级标题 */
#MdWechat h3 {
    font-size: 18px;
    font-weight: 600;
    color: #334155;
    margin: 1.4em 0 0.8em 0;
}

/* 列表 */
#MdWechat ul,
#MdWechat ol {
    color: #475569;
    padding-left: 20px;
    margin: 1em 0;
}

#MdWechat li {
    margin: 0.5em 0;
}

/* 重点设计：引用块 (Blockquote) - 圆角卡片阴影风 */
#MdWechat blockquote {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 1.5em 0;
    border: 1px solid rgba(124, 58, 237, 0.1);
    box-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.05), 0 2px 4px -1px rgba(124, 58, 237, 0.03);
    border-left: none;
}

#MdWechat blockquote p {
    color: #64748B;
    font-size: 14.5px;
    margin: 0;
}

#MdWechat blockquote::before,
#MdWechat blockquote::after {
    content: none;
}

/* 强调文字胶囊化 */
#MdWechat strong {
    font-weight: 600;
    color: #7C3AED;
    background: rgba(124, 58, 237, 0.1);
    padding: 2px 6px;
    border-radius: 6px;
}

#MdWechat em {
    font-style: italic;
    color: #3B82F6;
    background: transparent;
}

/* 链接 */
#MdWechat a {
    color: #3B82F6;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
}

/* 行内代码 */
#MdWechat p code,
#MdWechat li code {
    color: #EC4899;
    font-family: "Fira Code", "Courier New", monospace;
    background: #FCE7F3;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 13.5px;
}

/* 重点设计：悬浮代码块 */
#MdWechat pre {
    background: #1E293B;
    border-radius: 16px;
    padding: 20px;
    margin: 1.8em 0;
    overflow-x: auto;
    font-family: "Fira Code", Consolas, monospace;
    font-size: 13.5px;
    line-height: 1.6;
    box-shadow: 0 10px 15px -3px rgba(30, 41, 59, 0.3);
}

#MdWechat pre code {
    color: #E2E8F0;
    background: transparent;
    padding: 0;
}

#MdWechat .code-snippet__fix {
    background: #1E293B;
    border-radius: 16px;
}

/* 分隔线：渐变线 */
#MdWechat hr {
    height: 2px;
    border: none;
    background: linear-gradient(90deg, rgba(124, 58, 237, 0), rgba(124, 58, 237, 0.5), rgba(124, 58, 237, 0));
    margin: 2.5em 0;
}

/* 图片 */
#MdWechat img {
    border-radius: 16px;
    max-width: 100%;
    margin: 1.8em auto;
    display: block;
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.1);
}

#MdWechat figcaption {
    text-align: center;
    font-size: 13px;
    color: #94A3B8;
    margin-top: -1em;
}

/* 表格 */
#MdWechat table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5em 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

#MdWechat table tr th {
    background: #F1F5F9;
    color: #1E293B;
    font-weight: 600;
    padding: 12px;
    text-align: left;
}

#MdWechat table tr td {
    padding: 12px;
    color: #475569;
    background: #FFFFFF;
    border-top: 1px solid #F1F5F9;
}

path: scripts/convert.js
content: const fs = require('fs');
const path = require('path');
const cp = require('child_process');

const mdPath = process.argv[2];
const cssPath = process.argv[3];
const outPath = process.argv[4] || 'output.html';

if (!mdPath || !cssPath) {
    console.error('Usage: node convert.js <markdown_file> <css_file> [output_file]');
    process.exit(1);
}

function installAndRequire(packageName, moduleName, tempDir) {
    try {
        return require(moduleName);
    } catch (e) {
        console.log(`Installing ${packageName} temporarily...`);
        cp.execSync(`npm install ${packageName} --no-save`, { cwd: tempDir, stdio: 'ignore' });
        return require(path.join(tempDir, 'node_modules', moduleName));
    }
}

const tempDir = path.join(process.cwd(), '.wechat-temp');
if (!fs.existsSync(tempDir)) {
    fs.mkdirSync(tempDir);
    fs.writeFileSync(path.join(tempDir, 'package.json'), '{"name":"temp","private":true}');
}

try {
    const marked = installAndRequire('marked@4', 'marked', tempDir);
    const juice = installAndRequire('juice@8', 'juice', tempDir);

    console.log('Reading files...');
    const md = fs.readFileSync(path.resolve(mdPath), 'utf8');
    const css = fs.readFileSync(path.resolve(cssPath), 'utf8');

    console.log('Converting Markdown to HTML...');
    const html = marked.parse(md);
    const wrapped = '<section id="MdWechat">' + html + '</section>';

    console.log('Inlining CSS...');
    const finalHtml = juice.inlineContent(wrapped, css);

    fs.writeFileSync(path.resolve(outPath), finalHtml);
    console.log(`\n✅ Success! WeChat HTML generated at: ${outPath}`);
} catch (err) {
    console.error('❌ Error during conversion:', err.message);
} finally {
    try {
        if (fs.existsSync(tempDir)) {
            fs.rmSync(tempDir, { recursive: true, force: true });
        }
    } catch (e) { }
}


Security scan verdicts — ClawScan: clean | static analysis: suspicious | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)