Skip to content

feat(drive): convert Markdown uploads and strip YAML frontmatter#487

Open
johnbenjaminlewis wants to merge 1 commit intosteipete:mainfrom
johnbenjaminlewis:feat/drive-markdown-upload-frontmatter
Open

feat(drive): convert Markdown uploads and strip YAML frontmatter#487
johnbenjaminlewis wants to merge 1 commit intosteipete:mainfrom
johnbenjaminlewis:feat/drive-markdown-upload-frontmatter

Conversation

@johnbenjaminlewis
Copy link
Copy Markdown

@johnbenjaminlewis johnbenjaminlewis commented Apr 2, 2026

Summary

  • Markdown to Doc Conversion: Treat .md as convertible to native Google Docs when using gog drive upload --convert. (Uses application/vnd.google-apps.document metadata).
  • Frontmatter Handling: Strips leading YAML frontmatter (--- ... ---) by default to ensure clean Drive imports.
  • New Flag: Added --keep-frontmatter for users who want to preserve the header.
  • Implementation: Frontmatter removal is delimiter-based (no heavy YAML dependency). Centralized --- literal in internal/cmd/literals.go to satisfy goconst.
  • Documentation: Updated README and docs/spec.md to reflect new flags and existing Google Doc → Markdown export logic.

User-facing changes

  • gog drive upload file.md --convert: Creates a Google Doc; strips frontmatter.
  • gog drive upload file.md --convert --keep-frontmatter: Creates a Google Doc; keeps frontmatter.

Test plan

  • make ci
  • Unit tests: Validated stripYAMLFrontmatter, MIME conversion logic, and edge cases.
  • Manual: Verified against live Drive API (Doc creation and frontmatter stripping confirmed).

Relates to #272 (Provides a workaround via drive upload import).

Map .md to Google Doc conversion with --convert, strip leading
---/--- frontmatter before upload (opt out with --keep-frontmatter),
and extend tests for convert MIME and frontmatter handling.
gog drive download <fileId> --out ./downloaded.bin
gog drive download <fileId> --format pdf --out ./exported.pdf # Google Workspace files only
gog drive download <fileId> --format docx --out ./doc.docx
gog drive download <fileId> --format md --out ./note.md # Google Doc → Markdown
Copy link
Copy Markdown
Author

@johnbenjaminlewis johnbenjaminlewis Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The addition of gog drive download --format md ... to the README is for documentation completeness. I’ve included it here so that the Markdown import/export flows are documented together in the same section.

(The download as md feature was originally added in #282)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant