zhihu-md-publisher
GitHub用于将本地Markdown文章自动发布至知乎。支持解析元数据、处理图片、生成预览,并通过浏览器自动化填充编辑器、设置标签及封面,最终发布并更新链接。
Trigger Scenarios
Install
npx skills add fanfan-de/anybox --skill zhihu-md-publisher -g -y
SKILL.md
Frontmatter
{
"name": "zhihu-md-publisher",
"description": "Publish local Markdown articles to Zhihu from Codex. Use when the user asks to prepare, validate, automate, upload, or publish a .md article to Zhihu\/Zhuanlan, including parsing frontmatter, resolving local images, filling the Zhihu editor, setting topics, handling draft links, and updating the source Markdown with the published Zhihu URL."
}
Zhihu Markdown Publisher
Use this skill to move a local Markdown article into Zhihu's article editor and publish it with images. Treat Zhihu login, CAPTCHA, and final publishing as live external actions.
Required Inputs
Expect a Markdown article path. If the user does not provide one, search the workspace for likely Zhihu drafts under paths such as 03_内容生产/知乎.
The article should have frontmatter:
---
zhihu-title: 文章标题
zhihu-topics:
- 大语言模型
- 桌面应用
zhihu-cover:
zhihu-link:
---
Support body images in either Markdown or Obsidian wiki syntax:

![[assets/screenshot.png|说明]]
Workflow
- Run the bundled preparer:
node "<skill-dir>\scripts\prepare-zhihu-article.mjs" "<article.md>" "<output-dir>"
Use a workspace output directory such as 07_自动化脚本/out/zhihu. The script writes:
<name>.manifest.json: title, topics, cover, image paths, output paths.<name>.html: local preview.<name>.txt: plain-text fallback.
Stop and fix any missing frontmatter or missing images before using the browser.
-
Open
https://zhuanlan.zhihu.com/writein the in-app browser when available. If Zhihu redirects to login, ask the user to finish login/CAPTCHA, then continue. -
Fill the editor from the manifest:
- Put
manifest.titleinto the title textbox. - Clear the body if it contains an old draft or duplicate content.
- Paste rich HTML chunks, not raw Markdown, so headings/lists/links render correctly.
- Paste local images as clipboard image items in the original image order.
- Verify
figurecount equalsmanifest.images.length. - Verify raw Markdown heading text such as
##is not present. - Verify key tail content and links exist.
- Set publishing metadata:
- Add no more topics than Zhihu accepts. Prefer exact topic suggestions surfaced by Zhihu over forcing frontmatter names.
- If topic search returns ambiguous results, pick fewer high-confidence topics rather than incorrect ones.
- Leave column/question/source settings unchanged unless the user explicitly asks.
- Add a cover only if the page supports it reliably; otherwise rely on the article's first product image.
- Publish:
- Click final
发布only if the user explicitly asked to publish in this turn or already approved publishing. - After success, capture the final URL, usually
https://zhuanlan.zhihu.com/p/<id>. - Update the article frontmatter
zhihu-link:with the final URL. - Re-run the preparer once to verify the source still parses.
Browser Implementation Notes
Use the Browser/in-app browser skill when available. A robust sequence is:
- Inspect the current DOM and locate the two textboxes: title then body.
- Fill title.
- If the body must be cleared, click editor undo until the body is empty if ordinary
Ctrl+Adoes not work. Verify字数:0and zerofigureelements. - Paste chunks:
await tab.clipboard.write([{ entries: [
{ mimeType: "text/html", text: htmlChunk },
{ mimeType: "text/plain", text: plainChunk }
] }]);
await bodyBox.press("Control+V", { timeoutMs: 10000 });
- Paste each image:
await tab.clipboard.write([{ entries: [{
mimeType: "image/png",
base64: imageBytes.toString("base64")
}] }]);
await bodyBox.press("Control+V", { timeoutMs: 10000 });
Use image/jpeg for .jpg or .jpeg. Wait briefly after every image paste so Zhihu finishes inserting/uploading it.
Validation Checklist
Before publishing, check:
- Title textbox contains the intended title.
- Body has the intro and final paragraph.
- GitHub/download links are visible and clickable when present.
document.querySelectorAll("figure").lengthequals expected image count.- No duplicated body content.
- No raw heading markers remain, for example
## 是 Agent 工作台. - Topics are relevant and visible in publish settings.
- The
发布button is enabled.
If any validation fails, do not publish. Restore a clean draft and re-fill it.
Version History
- 08dc189 Current 2026-07-05 18:54


