publish-to-google-docs
Publish Markdown to Google Docs
Quickly publish markdown notes to styled Google Docs using pandoc and a Word template.
When to use
- User wants to publish a markdown note to Google Docs
- User says "publish to Google Docs", "create a Google Doc from markdown", or "push this to Drive"
- User wants to apply consistent branding/styling to documents before sharing
Prerequisites
- pandoc - Must be installed (see self-healing below)
- A Word template (.docx) with desired styles
- OAuth credentials for Google Drive (one-time setup)
Self-healing: Installing pandoc
If pandoc is not installed, ask the user how they would like to install it:
Preferred option (pixi):
pixi global install pandoc
Alternative options by platform:
| Platform | Command |
|---|---|
| macOS (Homebrew) | brew install pandoc |
| macOS (MacPorts) | port install pandoc |
| Windows (Chocolatey) | choco install pandoc |
| Windows (winget) | winget install --source winget --exact --id JohnMacFarlane.Pandoc |
| Linux (Conda) | conda install -c conda-forge pandoc |
| Any (download) | Download from https://github.com/jgm/pandoc/releases/latest |
Use the question tool to present these options if pandoc is missing.
Workflow
Step 1: Check pandoc availability
which pandoc && pandoc --version
If not found, prompt user to install (see self-healing above).
Step 2: Convert markdown to docx with pandoc
pandoc INPUT.md --from markdown --to docx --reference-doc=TEMPLATE.docx --output=OUTPUT.docx
The --reference-doc flag applies the template's styles (fonts, headings, margins) to the output.
Step 3: Upload to Google Drive
uv run scripts/upload_to_drive.py --input OUTPUT.docx --title "Document Title"
Returns a shareable Google Docs link.
Example
# Convert and upload
pandoc "proposal.md" --from markdown --to docx --reference-doc="template.docx" --output="proposal.docx"
uv run scripts/upload_to_drive.py --input "proposal.docx" --title "My Proposal"
Scripts
upload_to_drive.py
Uploads a docx file to Google Drive using OAuth2 user authentication.
Usage:
uv run scripts/upload_to_drive.py --input /path/to/file.docx --title "Document Title"
Setup (one-time):
- Go to https://console.cloud.google.com/apis/credentials
- Create an OAuth 2.0 Client ID (Desktop app)
- Set environment variables:
export GOOGLE_CLIENT_ID='your-client-id.apps.googleusercontent.com'
export GOOGLE_CLIENT_SECRET='your-client-secret'
Features:
- Opens browser for Google login on first run
- Saves credentials locally for future use
- Use
--logoutto remove saved credentials - Use
--no-shareto keep document private
Template Style Requirements
For best results, your template should have these styles defined:
| Style | Usage |
|---|---|
| Title | Document title (# heading) |
| Heading 1 | Major sections (## heading) |
| Heading 2 | Subsections (### heading) |
| Heading 3 | Sub-subsections (#### heading) |
| Normal | Body paragraphs |
Notes
- Pandoc handles all markdown correctly: lists, bold, italic, tables, code blocks, links
- The template's fonts, colors, and margins are preserved via
--reference-doc - Images from the template are not copied - this only applies styles
More from ericmjl/skills
html-presentations
Create single-file HTML slide presentations with vanilla JS/CSS. Themed (terminal.css, catppuccin, nord), keyboard-navigable, with inline SVG diagrams and animations. Use when the user asks for an HTML presentation, slide deck, or single-file slides without a framework.
29agents-md-improver
Proposes updates to AGENTS.md so repo-local coding-agent instructions stay accurate, non-contradictory, and consolidated. Use when the user corrects the agent (e.g. do not do X, always do Y, from now on, remember this), asks to edit or sync AGENTS.md, CLAUDE.md, .claude/CLAUDE.md, or GEMINI.md, wants one canonical instruction file or to deduplicate agent docs, or flags conflicting or outdated repository agent rules.
22scientific-eda
Defensive exploratory data analysis for scientific data (CSV, FASTA, etc.). Context-first, human-guided; one plot at a time, ask why before executing, append-only journal per session, scripts with PEP723 and uv run, WebP plots. Use when opening data files for EDA or when the user wants guided scientific data exploration.
20skill-creator
Guide for authoring Agent Skills with strong YAML `description` triggers, progressive disclosure, and bundled resources. Use when creating or updating a skill, running init_skill.py or package_skill.py, or improving a bland skill description so agents load the skill on the right user tasks.
18ml-experimentation
Conduct machine learning experiments from planning through evaluation and report writing. Use when running ML experiments, testing hypotheses, training models, or writing up results. Covers single-hypothesis scoping, fast iteration loops, targeted logging, JOURNAL.md protocol, data-backed diagnostic plots, and scientific report writing.
16gh-cli
Use GitHub CLI (gh) for common operations like creating PRs, viewing GitHub Actions logs, managing issues, reviewing PRs, and more. Use this when you need to interact with GitHub repositories directly from the command line.
14