Overview
This is a Skill for converting standard Markdown text into an HTML file that can be directly copied and pasted into the WeChat Official Account article editor. The HTML structure of WeChat Official Accounts requires all styles 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 lightweight by executing the conversion script included with this Skill. It will automatically load the required dependencies in a temporary directory and clean them up after completion, leaving no environment garbage, without the user needing to run npm install。
Applicable scenarios
When the user wants you to:
- Convert md or markdown format files into WeChat Official Account articles.
- Generate WeChat Official Account layout HTML with CSS styles based on Markdown.
Detailed execution steps
When you receive a conversion request from the user, if no theme is specified, use the default resources/themes/default.css。
Pleasedirectlyexecute the following command on behalf of the user, calling the included scripts/convert.js. If you are using a tool (such as Terminal / run_command), simply call it directly.
Run the conversion script
Use node to perform the conversion:
node <当前skill路径>/scripts/convert.js <用户指定的markdown文件> <选择的主题css文件> <输出目标html文件路径>
(For example, convert input.md to output.html:node wechat-markdown-skill/scripts/convert.js input.md wechat-markdown-skill/resources/themes/default.css output.html)
with the default theme. The script will automatically and safely handle Markdown conversion, add the <section id="MdWechat"> WeChat container, and inline-inject the specified CSS theme.
Note: The current theme system carries CSS variables (such as --text-color) in the container root node, so that multiple themes can share color semantics. If you later want to use zhy-wechat-publish to upload to the draft box, you should use its latest release script, which will automatically expand var(--xxx)before uploading, avoiding the loss of color styles in the WeChat backend.
Deliver the output result
After completion, directly tell 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."
Theme support (Themes)
The resources/themes/ in this directory can store multiple different CSS theme schemes.
If the user requests a change of theme style, you can view and read the paths of the CSS files that exist in this directory and pass them to the script, which makes this Skill naturally support a "skinning" feature.