Skip to content

fix(docs): size markdown images on write#518

Closed
vinothd-oai wants to merge 1 commit intoopenclaw:mainfrom
vinothd-oai:codex/docs-write-markdown-images
Closed

fix(docs): size markdown images on write#518
vinothd-oai wants to merge 1 commit intoopenclaw:mainfrom
vinothd-oai:codex/docs-write-markdown-images

Conversation

@vinothd-oai
Copy link
Copy Markdown
Contributor

@vinothd-oai vinothd-oai commented Apr 21, 2026

Summary

  • extract Markdown image references before gog docs write --replace --markdown uploads content through Drive
  • upload cleaned Markdown with placeholders, then reuse the existing Docs image insertion path
  • preserve remote image support, local image resolution relative to --file, default sizing, custom width/height attrs, pageless behavior, and existing output shape

Why

gog docs create --file already handles Markdown images in two passes: it strips image Markdown into placeholders before Drive import, then reads the converted Google Doc and inserts images through the Docs API with explicit sizing. That keeps large source images from being imported at their natural dimensions and gives users consistent defaults such as the 468pt max width.

gog docs write --replace --markdown was taking a different path. It sent the raw Markdown body directly to Drive update, which let Drive import image references itself. That bypassed the existing sizing logic, so large images could become oversized in the resulting Google Doc.

This change makes the write path follow the same pattern as document creation: extract images first, let Drive convert the cleaned Markdown, then reuse insertImagesIntoDocs to place remote or local images with the same default and explicit width/height handling.

Validation

  • go test ./internal/cmd -run "TestDocsWrite_Markdown"
  • go test ./internal/cmd -run "TestDocsWrite"
  • git diff --check

Note: go test ./internal/cmd still fails locally on an unrelated auth-state-sensitive TestRequireAccount_Missing because this environment has actual@example.com configured.

@vinothd-oai vinothd-oai marked this pull request as ready for review April 21, 2026 07:34
@steipete
Copy link
Copy Markdown
Collaborator

Thanks @vinothd-oai, landed this on main via e97cad6 with follow-up live-test hardening in acb05f6.

I kept the core fix: docs write --replace --markdown now extracts remote Markdown images before Drive conversion and reinserts them through Docs so sizing is applied consistently. During live testing, Google Docs rejected temporary Drive-hosted local images even after sharing/retry, so I adjusted the landed version to return a clear error for local image paths and document public HTTPS image URLs as the supported path.

Validation performed:

  • make ci
  • live reauth for steipete@gmail.com with docs/drive/gmail/people scopes
  • live Docs remote-image write smoke with placeholder removal + inline object check
  • live local-image clear-error smoke
  • live Gmail draft create/get/delete smoke.

@steipete steipete closed this Apr 27, 2026
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.

2 participants