SuperAPI AI Directory

markdown2wechat

General & other

View repository

Updated 10-16 09:30

About this skill

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 that all styles must 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 in an extremely lightweight way by running 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 clutter, and the user does not need 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 formatted HTML with CSS styles based on Markdown.

Detailed Execution Steps

When you receive a user's conversion request, if no theme is specified, use resources/themes/default.css。

Pleasedirectlyrun the following command on behalf of the user, calling the scripts/convert.jsincluded with this Skill. 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)

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 wechat-publish to upload to the drafts 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, copy, and 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 CSS file paths that exist in that directory and pass them to the script. This makes this Skill naturally support a "skin-changing" feature.