Description
Convert WeChat Official Account article links to Markdown format, extract the title, author, and body content, and generate a Markdown file with YAML frontmatter.
Use Cases
- The user provides a WeChat Official Account article link and requests conversion to Markdown
- Need to save a WeChat Official Account article as a local Markdown file
- Need to extract WeChat article content for archiving or editing
Should not trigger:
- Conversion of links on non-WeChat Official Account domains
- The user only needs to extract plain text and does not request format conversion
- Paid articles that require login to access
Instructions
Step 1. Validate the input link
Check whether it is a link on the mp.weixin.qq.com domain.
Decision branch:
- Valid WeChat link: proceed to Step 2
- Non-WeChat link: indicate that only WeChat Official Account article links are supported, and exit execution
Step 2. Choose the execution method and obtain the content
Decision branch:
-
Script available(
scripts/package.jsonexists and Node.js >= 22.18.0 is available): use the script to perform the conversion, and proceed directly to Step 4node scripts/ <url> [output-path] -
Script unavailable: manually fetch the web page content, and proceed to Step 3
Decision branch when the script is unavailable:
- Request successful: proceed to Step 3
- Request failed: output the error status code and reason, and exit execution
Step 3. Manually extract information and convert
Perform this step only when the script is unavailable in Step 2.
- Extract the article title and author/Official Account name
- Extract
js_contentthe body HTML of the region - Convert HTML tags to Markdown format (headings, bold, lists, quotes, code blocks, links, images, etc.)
- Automatically handle WeChat lazy-loaded images (
data-src) and HTML entity escaping
Decision branch:
- Body extraction successful: proceed to Step 4
- Body empty: indicate that it may be a paid article or require login, and exit execution
Step 4. Output the result
Assemble the complete Markdown (including YAML frontmatter: title, author, source, date).
Decision branch:
- User specifies an output path: save as a file, and output the save location and character statistics
- User does not specify a path: output the Markdown text directly
Related Resources
This skill includes the following auxiliary resources:
scripts/src/cli.ts: CLI entry scriptscripts/src/parser/html-to-md.ts: HTML to Markdown modulescripts/src/parser/extract-meta.ts: article metadata extraction modulescripts/src/parser/extract-body.ts: body region extraction module