MDToSM is a desktop-only Obsidian plugin for formatting Markdown notes and publishing them to WeChat Official Accounts. It provides a compact right-side workspace for previewing, styling, exporting, and submitting articles and image cards.
The plugin converts Markdown notes into WeChat-compatible HTML, preserves local images, supports local cover cropping, and creates drafts through the official WeChat API. Users can choose from multiple article layouts, color themes, mobile and desktop previews, long-image export modes, and image-card drafts with optional text descriptions.
MDToSM is designed for personal desktop use. AppSecret values are stored in the macOS Keychain. The plugin reads the active note through the Obsidian Vault API, does not send note content to an external rendering service, and does not execute user-provided shell commands. The only system command used is the fixed macOS /usr/bin/security tool with fixed arguments for Keychain access.
To install the plugin manually, download main.js, manifest.json, and styles.css from a matching GitHub Release and copy them to <vault>/<config-dir>/plugins/ob-article-to-sm/. Then enable MDToSM in Obsidian's Community plugins settings. See the Chinese documentation below for configuration and usage details.
Install the three files from the matching GitHub Release (main.js, manifest.json, and styles.css) into <vault>/<config-dir>/plugins/ob-article-to-sm/, then enable MDToSM in Obsidian's Community plugins settings. The plugin stores AppSecret values in the macOS Keychain by invoking the fixed system tool /usr/bin/security with fixed command arguments; it does not run user-provided shell commands or write secrets to plugin data files.
MDToSM 是用于微信公众号排版、草稿发布和贴图导出的 Obsidian 第三方插件。打开右侧紧凑工作台后,可预览当前笔记、切换主题、选择公众号账号、创建草稿或直接提交发布,也可把笔记生成贴图并保存到 Vault 或公众号草稿箱。
Cmd + P → 打开公众号发布工作台;未配置账号也可以刷新完整文章预览名称|AppID|AppSecret 每行配置一个账号,AppSecret 使用 macOS 钥匙串加密保存![[image.png|120x80]] 自动转换;保存草稿时上传到微信并替换为微信 CDN 地址2x 倍率生成 PNG贴图导出/<文章名>/,也可创建纯图片或图片加文字描述的公众号贴图草稿npm install
npm run build
mkdir -p "<vault>/<config-dir>/plugins/ob-article-to-sm"
cp main.js manifest.json styles.css "<vault>/<config-dir>/plugins/ob-article-to-sm/"
然后在 Obsidian 的“设置 → 第三方插件”中启用 MDToSM。
从 md-to-sm、obsidian-to-sm 或 wechat-article-studio 升级时,首次启用新版会自动迁移账号配置和本地封面到 .obsidian/plugins/ob-article-to-sm/。迁移成功后可在“设置 → 第三方插件”中停用旧版插件。
frontmatter 可省略;未填写时,标题默认取笔记的第一个 H1 或文件名,作者取插件设置。
---
标题: 我的公众号文章
作者: 张三
摘要: 这是一段用于公众号展示的摘要。
打开评论: true
仅粉丝可评论: false
---
# 我的公众号文章
正文中的本地图片:![[diagram.png|800]]
也支持对应英文键:title、author、digest、cover、need_open_comment、only_fans_can_comment。
在插件设置中填写 AppID 和 AppSecret。公众号后台还必须满足:
access_token、上传素材和创建草稿的 API 权限。thumb_media_id。如果未满足 IP 白名单或 API 权限,插件会显示微信返回的错误,草稿不会创建。
打开公众号发布工作台。执行 复制当前笔记到公众号,在预览窗口检查样式后点击“复制到公众号”,将富文本粘贴到公众号编辑器。
16000px 时插件会停止生成,并提示切换到多页模式;公众号贴图草稿最多支持 20 张图片。分割线切片会优先按 Markdown 的 --- 分页;单段内容仍然过长时,会继续按正文块边界智能切分。导出时不会覆盖旧文件,同名文章会自动增加批次序号。
npm run build
npm test
手动验证:安装插件后,用包含标题、代码和本地正文图的笔记选择本地封面并执行一键保存。成功时公众号草稿箱会出现文章;重点检查标题、摘要、封面、正文图片和代码块。
贴图验证:切换手机画框、单图、多图和分割线模式,确认表格、代码、本地图片与 PNG 一致,并检查 Vault 中导出的图片可以正常打开。
维护者发布新版本时,先更新 manifest.json、package.json 和 versions.json 的版本号,执行 npm test 与 npm run build。随后创建与版本号一致的 GitHub Release,并上传 main.js、manifest.json、styles.css 三个附件。首次提交到 Obsidian 社区目录前,请确认仓库公开、README、LICENSE 和 第三方声明 均位于仓库根目录。
第三方组件及许可见 第三方声明。