markpress
npx skills add https://github.com/liustack/markpress --skill markpress
Agent 安装分布
Skill 文档
markpress â WeChat + X Articles HTML
CLI tool to convert Markdown into editor-compatible HTML:
- WeChat Official Account (å ¬ä¼å·) mode
- X/Twitter Articles mode
Installation
npm install -g @liustack/markpress@latest
Version check: Before converting, run
markpress --version. If the command is not found or the version is outdated, re-run the install command above.
Playwright Chromium (Required for Mermaid)
mermaid and playwright are bundled as dependencies. After installing markpress, download the Chromium browser binary:
npx playwright install chromium
Without Chromium, mermaid code blocks will trigger an error. All other features work without it.
Usage
# Convert Markdown to WeChat-ready HTML (file output)
markpress -i article.md -o output.html
# Convert Markdown to X/Twitter Articles-ready HTML
markpress -i article.md -o output.html --target x
# Convert and copy to system clipboard (for direct paste into WeChat editor)
markpress -i article.md -o output.html --copy
Output is JSON:
{
"input": "/absolute/path/to/article.md",
"output": "/absolute/path/to/output.html",
"size": 12345
}
Options
-i, --input <path>â Input Markdown file path (required)-o, --output <path>â Output HTML file path (required)-t, --target <target>âwechat(default),x, ortwitter(alias ofx)-c, --copyâ Copy rendered HTML to system clipboard as rich text (for direct paste into WeChat editor)
X/Twitter Articles Mode
Use --target x (or --target twitter) for X Articles editor:
- Keep only semantic subset:
h2,p,strong/b,em/i,s/del,a,blockquote,ul/ol/li,br - Convert every image to placeholder text:
[Image: ...] - Remove unsupported structure/style tags
- Keep only
https://links as<a href="..."> - Convert
//...links tohttps://... - Downgrade non-HTTPS links (
http,mailto,tel,file, relative paths, anchors) to plain text
Mandatory Workflow (AI Agent MUST Follow)
[!CAUTION] Every Markdown-to-WeChat conversion MUST follow these steps. Do NOT skip or reorder.
- Prepare Markdown â Write or locate the Markdown file. Ensure all images use relative paths from the Markdown file’s directory.
- Confirm output path â Decide where the HTML should be saved (the
-opath). - Run markpress â Execute the conversion:
Or with clipboard copy:markpress -i article.md -o output.htmlmarkpress -i article.md -o output.html --copy - Check result â Verify the JSON output shows a successful result with
size > 0. - Deliver â Tell the user the output HTML path. If
--copywas used, inform them the HTML is ready to paste directly into the WeChat MP editor.
WeChat MP Editor Constraints
[!IMPORTANT] The WeChat MP editor has strict limitations. markpress handles all of these automatically, but the AI agent should understand the constraints to verify output quality.
- Inline styles only â no
<style>,<link>, or<script>tags; all CSS must be instyleattributes - Base64 images â local images are compressed (sharp) and converted to base64 data URIs (⤠2MB per image)
- Tag whitelist â only WeChat-supported tags survive;
<div>â<section>, dangerous tags removed entirely - Code whitespace â
\nâ<br>, all spaces â NBSP, tabs â NBSP pairs;text-align: lefton code blocks to prevent WeChat justify - External links â footnotes â external
<a>tags become text +<sup>[N]</sup>with a References section;mp.weixin.qq.comlinks are preserved - No class attributes â all
classNameremoved; hljs syntax highlighting classes converted to inline color styles
Image Handling
| Source | Behavior |
|---|---|
| Local file (relative path) | Compressed via sharp â base64 data URI (PNG preferred, ⤠2MB) |
data: URI |
Skipped (already inline) |
http:// / https:// URL |
Skipped (passed through as-is) |
| GIF | Preserved as animated GIF, resized if > 2MB |
| SVG | Rasterized to PNG via sharp (WeChat doesn’t support data:image/svg+xml) |
[!CAUTION] Images must use relative paths from the Markdown file location. Absolute paths or URLs to local files won’t resolve correctly.
Pipeline Processing Order
markpress applies these transformations in sequence:
Markdown â remarkParse â remarkGfm â remarkRehype â rehypeRaw
â 1. rehypeSanitizeTags (tag whitelist, divâsection, checkboxâUnicode, attribute cleanup)
â 2. rehypeMermaid (mermaid code blocks â Playwright render â PNG base64, optional)
â 3. rehypeBase64Images (local images â sharp compress â base64 data URI)
â 4. rehypeCodeHighlight (syntax highlighting + whitespace protection)
â 5. rehypeFootnoteLinks (external links â footnotes, preserve mp.weixin.qq.com)
â 6. rehypeInlineStyles (default styles + hljs colors â inline style attr, remove className)
â rehypeStringify â HTML
Output Verification Checklist
After conversion, the output HTML should have:
- No
class=attributes - No
<script>,<style>,<link>,<iframe>,<input>,<div>tags - All visible elements have
style=attributes - External links replaced with footnote references (
<sup>[N]</sup>) - A
Referencessection at the end (if external links existed) - Code blocks use
<br>for line breaks and NBSP for indentation - Local images converted to
data:image/...;base64,... - Task list checkboxes rendered as â / â
- Mermaid code blocks converted to PNG
<img>(if mermaid + playwright installed)