zhy-markdown2wechat
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese概述
Overview
这是一个用于将标准的 Markdown 文本,转换成能够直接复制粘贴给微信公众号文章编辑器的 HTML 文件的 Skill。微信公众号的 HTML 结构要求所有样式必须是内联的(Inline CSS)。
此 Skill 的核心优势是 零部署。只要用户的环境中安装了 Node.js,即可通过执行本 Skill 自带的转换脚本极其轻量地完成转换任务,它会自动在临时目录加载所需依赖并在完成后清理,不留任何环境垃圾,无需用户预先执行 。
npm installThis is a Skill that converts standard Markdown text into HTML files that can be directly copied and pasted into the WeChat Official Account article editor. WeChat Official Account requires all styles in HTML to be inline (Inline CSS).
The core advantage of this Skill is zero deployment. As long as Node.js is installed in the user's environment, the conversion task can be completed extremely lightly by executing the built-in conversion script of this Skill. It will automatically load the required dependencies in a temporary directory and clean up after completion, leaving no environment garbage, and no need for users to run in advance.
npm install适用场景
Application Scenarios
当用户希望你:
- 把 md、markdown 格式的文件转为微信公众号文章。
- 根据 Markdown 生成带 CSS 样式的公众号排版 HTML。
When users ask you to:
- Convert .md / Markdown files into WeChat Official Account articles.
- Generate WeChat Official Account formatted HTML with CSS styles from Markdown.
详细执行步骤
Detailed Execution Steps
当你收到用户的转换请求时,如果不指定主题,默认使用 。
resources/themes/default.css请你直接代用户执行以下命令,调用本 Skill 自带的 。如果你在使用工具(例如 Terminal / run_command),请直接调用即可。
scripts/convert.jsWhen you receive a conversion request from a user, if no theme is specified, will be used by default.
resources/themes/default.cssPlease directly execute the following command on behalf of the user to call the built-in of this Skill. If you are using tools (such as Terminal / run_command), just call it directly.
scripts/convert.js执行转换脚本
Execute the Conversion Script
使用 执行转换:
nodebash
node <当前skill路径>/scripts/convert.js <用户指定的markdown文件> <选择的主题css文件> <输出目标html文件路径>(例如将 转换为带默认主题的 :)
input.mdoutput.htmlnode wechat-markdown-skill/scripts/convert.js input.md wechat-markdown-skill/resources/themes/default.css output.html脚本将会自动安全地处理 Markdown 转换、增加 微信容器、内联注入指定的 CSS 主题。
<section id="MdWechat">注意:当前主题体系会在容器根节点中携带 CSS 变量(如 ),以便多主题共享配色语义。若后续要通过 上传到草稿箱,应使用其最新发布脚本,它会在上传前自动展开 ,避免微信后台丢失颜色样式。
--text-colorzhy-wechat-publishvar(--xxx)Execute the conversion with :
nodebash
node <当前skill路径>/scripts/convert.js <用户指定的markdown文件> <选择的主题css文件> <输出目标html文件路径>(Example: Convert to with the default theme: )
input.mdoutput.htmlnode wechat-markdown-skill/scripts/convert.js input.md wechat-markdown-skill/resources/themes/default.css output.htmlThe script will automatically and safely handle Markdown conversion, add the WeChat container , and inline-inject the specified CSS theme.
<section id="MdWechat">Note: The current theme system carries CSS variables (such as ) in the root node of the container to share color semantics across multiple themes. If you need to upload to the draft box via later, please use its latest publishing script, which will automatically expand before uploading to prevent color styles from being lost in the WeChat backend.
--text-colorzhy-wechat-publishvar(--xxx)交付输出结果
Deliver the Output Result
完成后,直接告诉用户:"您的公众号 HTML 已生成在 中,可直接在浏览器打开预览效果,或用编辑器/浏览器打开后全选复制,粘贴到微信公众号后台即可。"
[目标文件]After completion, directly inform the user: "Your Official Account HTML has been generated in . You can open it directly in a browser to preview the effect, or open it with an editor/browser, select all and copy, then paste it into the WeChat Official Account backend."
[target file]主题支持 (Themes)
Theme Support
本目录下的 可以存放多套不同的 CSS 主题方案。
如果用户要求更换主题风格,你可以查看并读取该目录下存在的 CSS 文件路径并传递给脚本,这使得该 Skill 天然支持“换肤”功能。
resources/themes/Multiple sets of different CSS theme schemes can be stored in the directory under this Skill.
If the user requests to change the theme style, you can view and read the paths of existing CSS files in this directory and pass them to the script, which makes this Skill naturally support the "skin change" feature.
resources/themes/