Publishing Markdown to Substack from an Agent Skill
说明与用途
使用 publishing‑kit 代理自动将 Markdown 文章发布到 Substack,保留代码块、图片和链接,并审核已保存的草稿。
问题
Substack lacks a publishing API, so posts must be pasted into its web editor, which silently drops or alters certain content such as tables, inline‑code links, and LaTeX‑marked code blocks.
结果
The workflow successfully publishes a Markdown article to Substack while preserving code blocks, images, and links, and provides a programmatic audit of the draft content.
工作流
- Build Medium‑style HTML with python3 make‑medium.py, ensuring tables and diagrams are PNGs in medium/img/
- Serve the HTML locally on 127.0.0.1 and store it in window.name along with a helper script
- Open https://
<pub>.substack.com/publish/post?type=newsletter to create a new draft - Parse window.name, run ss.prepare() to unwrap inline‑code links, promote headings, and strip language classes
- Execute ss.paste() to paste the prepared HTML into the editor
- Use ss.audit() to confirm the draft contains the expected counts of code blocks, images, headings, and links
- Set title and subtitle with ss.setTitle(), ensuring subtitle ≤255 characters
- Open the Publish dialog with ss.openPublish() and confirm default settings before clicking "Send to everyone now"
证据
Substack has no publishing API. A post goes in through its web editor, and that editor decides what survives.
The fix is to take the <code><code></code> out of the anchor before pasting. The link survives as plain text, which keeps the reader's way to the page.
Substack keeps it as a real code block.
The subtitle has a limit of 255 characters, and going over it stops the whole draft saving, body included, while the editor still shows everything.
- 记录日期: 2026-10-05T18:56:00.777Z