Markdown一键转谷歌文档
简介
基于gog CLI的文档转换技能,将Markdown文件精准转换为格式规范的Google Docs,保留完整层级结构与样式。
原始描述
Convert markdown files to properly formatted Google Docs. Use when asked to create a Google Doc from markdown, upload markdown to Google Docs, put a .md file...
通过你的 Agent 添加
安装目录:md-to-gdoc/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
md-to-gdoc 是一个专注于 Markdown 到 Google Docs 格式转换的自动化工具技能。其核心工作流程遵循两步确定性策略:首先创建一个空白的 Google Doc,随后通过 gog docs update --format=markdown 命令将 Markdown 内容注入并自动应用 Google Docs 原生格式。
用户通过命令行调用脚本 scripts/md-to-gdoc.sh,传入 Markdown 文件路径及可选参数(标题、目标文件夹ID、指定Google账户)。技能严格依赖 gog(Google Workspace CLI)进行身份验证和API操作,同时借助 python3 完成JSON解析。关键约束在于必须使用 update --format=markdown 路径,而非 write 或 create --file,这是唯一能正确通过API应用Google Docs标题样式的官方途径。
显著优点
格式保真度高:能够完整转换六级标题层级(Heading 1-6)、粗体、行内代码、代码块、引用、列表、超链接,甚至Markdown表格也能转为原生Google Docs表格。
流程可靠性:采用"先创建空文档再更新内容"的两步策略,避免了直接创建带内容文档时常见的格式丢失问题,输出结果具有确定性。
身份验证灵活:支持多Google账户管理,可通过 --account 指定或回退到默认账户,适应团队协作场景。
错误预警机制:当检测到Markdown缺少 # 标题标记时主动发出警告,帮助用户提前修正源文件。
潜在缺点与局限性
依赖外部CLI生态:核心功能完全绑定 gog 工具,需用户提前完成 gog auth add <email> 认证流程,增加了环境配置门槛。
格式渲染瑕疵:斜体(*italic*)因gog CLI的inline解析器缺陷可能无法渲染;无序/有序列表仅使用文本前缀符号(•、1.)而非Google Docs原生列表对象,丧失部分交互特性;水平线被降级为40个连字符的文本模拟。
无自动标题修复:虽然会警告缺失#标记的标题,但不会自动为"看起来像标题的纯文本"添加标记,仍需人工预处理。
适合的目标群体
- 技术写作团队:需要将Git仓库中的Markdown文档(如README、技术规范)同步到Google Workspace进行协作审阅
- 学术研究人员:整理Markdown笔记后转换为符合机构格式要求的Google Docs提交材料
- 产品经理与运营:将Markdown形式的需求文档、PRD快速转换为可评论、可共享的协作文档
- 开发者工具链用户:已在工作流中集成
gog CLI,追求命令行自动化而非手动复制粘贴
常规使用风险
gog CLI,追求命令行自动化而非手动复制粘贴认证过期风险:gog 的OAuth令牌可能过期,表现为"Empty doc created"或授权错误,需定期执行 gog auth list 检查并重新 auth add。
API依赖风险:功能完全依赖Google Docs API的update端点,若Google调整API行为或 gog 版本滞后,可能导致格式映射失效。
路径解析风险:脚本路径 scripts/md-to-gdoc.sh 要求相对此skill目录解析,在复杂目录结构或符号链接环境下可能触发路径错误。
Python环境风险:JSON解析依赖系统 python3,在精简容器环境或Python版本冲突场景下可能执行失败。
技能正文
name: md-to-gdoc
version: 1.0.1
description: Convert markdown files to properly formatted Google Docs. Use when asked to create a Google Doc from markdown, upload markdown to Google Docs, put a .md file into Google Docs, or convert research/notes/documents to Google Docs format.
Markdown to Google Doc
Convert .md files into Google Docs with proper heading styles, bold, code blocks, lists, links, and blockquotes.
Requirements
- gog — Google Workspace CLI (must be authenticated:
gog auth add <email>)
- python3 — used for JSON parsing in the script
Quick Start
scripts/md-to-gdoc.sh <file.md> [--title "Title"] [--parent <folder-id>] [--account <email>]
gog auth add <email>)scripts/md-to-gdoc.sh <file.md> [--title "Title"] [--parent <folder-id>] [--account <email>]
Resolve scripts/ relative to this skill's directory.
Critical Rules
- Use
gog docs update --format=markdown — never write --markdown, never create --file. The update path is the only one that correctly applies Google Docs heading styles via the API.
- Markdown must have proper
# headings. If the source has "heading-looking" plain text without # markers, add them before conversion. The script warns but proceeds.
- Two-step process: create empty doc → populate with
update. This is deterministic and reliable.
- Always verify heading syntax in the markdown before running. No
# = no formatted headings in the output.
What Works
#–###### headings → Google Docs Heading 1–6
**bold** → bold text
`inline code` → Courier New
- Fenced code blocks → Courier New + gray background
> blockquotes → indented paragraphs
- bullets → bullet-prefixed text
1. numbered → number-prefixed text
[text](url) → hyperlinks
- Markdown tables → native Google Docs tables
Known Limitations
*italic* may not render (gog CLI bug in inline formatting parser — italic detection fails in certain contexts)
- Bullet/numbered lists use text prefixes (
•, 1.), not native Google Docs list objects
- Horizontal rules render as 40 dashes
Options
--title — Doc title. Defaults to filename with hyphens→spaces.
--parent — Google Drive folder ID to place the doc in.
--account — Google account email. Defaults to gog's default (first authenticated account).
Troubleshooting
- All body text, no headings: The markdown file lacks
# heading markers. Add them.
- gog auth errors: Run
gog auth list to verify auth. May need gog auth add <email>.
- Empty doc created: The
update step failed. Check gog output for API errors.
gog docs update --format=markdown — never write --markdown, never create --file. The update path is the only one that correctly applies Google Docs heading styles via the API.# headings. If the source has "heading-looking" plain text without # markers, add them before conversion. The script warns but proceeds.update. This is deterministic and reliable.# = no formatted headings in the output.#–######headings → Google Docs Heading 1–6**bold**→ bold text`inline code`→ Courier New- Fenced code blocks → Courier New + gray background
> blockquotes→ indented paragraphs- bullets→ bullet-prefixed text1. numbered→ number-prefixed text[text](url)→ hyperlinks- Markdown tables → native Google Docs tables
Known Limitations
*italic* may not render (gog CLI bug in inline formatting parser — italic detection fails in certain contexts)
- Bullet/numbered lists use text prefixes (
•, 1.), not native Google Docs list objects
- Horizontal rules render as 40 dashes
Options
--title — Doc title. Defaults to filename with hyphens→spaces.
--parent — Google Drive folder ID to place the doc in.
--account — Google account email. Defaults to gog's default (first authenticated account).
Troubleshooting
- All body text, no headings: The markdown file lacks
# heading markers. Add them.
- gog auth errors: Run
gog auth list to verify auth. May need gog auth add <email>.
- Empty doc created: The
update step failed. Check gog output for API errors.
*italic* may not render (gog CLI bug in inline formatting parser — italic detection fails in certain contexts)•, 1.), not native Google Docs list objects--title— Doc title. Defaults to filename with hyphens→spaces.--parent— Google Drive folder ID to place the doc in.--account— Google account email. Defaults to gog's default (first authenticated account).
Troubleshooting
- All body text, no headings: The markdown file lacks
# heading markers. Add them.
- gog auth errors: Run
gog auth list to verify auth. May need gog auth add <email>.
- Empty doc created: The
update step failed. Check gog output for API errors.
# heading markers. Add them.gog auth list to verify auth. May need gog auth add <email>.update step failed. Check gog output for API errors.正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。