Skip to content

feat: add docs update command for editing Google Docs#219

Merged
steipete merged 12 commits intoopenclaw:mainfrom
goncaloalves:feat/docs-update-command
Feb 13, 2026
Merged

feat: add docs update command for editing Google Docs#219
steipete merged 12 commits intoopenclaw:mainfrom
goncaloalves:feat/docs-update-command

Conversation

@goncaloalves
Copy link
Copy Markdown
Contributor

@goncaloalves goncaloalves commented Feb 10, 2026

Summary

This PR adds comprehensive markdown support to gog docs update and gog slides commands, enabling rich formatting conversion from markdown to native Google Docs/Slides elements.

Features Added

📄 Docs Update Command (gog docs update)

Core functionality:

  • Replace entire document content or append to existing
  • Support for plain text and markdown formats

Markdown → Google Docs conversion:

  • Headings (H1-H6) → Native heading styles
  • Bold (**text**) → Bold formatting
  • Italic (*text*) → Italic formatting
  • Inline code (`code`) → Monospace font
  • Links ([text](url)) → Clickable hyperlinks
  • Lists (- item, * item, 1. item) → Bullet/numbered lists
  • Code blocks (```) → Monospace + gray background
  • Blockquotes (> text) → Indented paragraphs
  • Horizontal rules (---, ***, ___) → Separator lines
  • Tables → Native Google Docs tables (with header row bold)

Table support:

  • Native Google Docs tables (not formatted text!)
  • Multi-step API: insert table → fetch indices → populate cells
  • Header rows automatically bold
  • Proper cell alignment

📊 Slides Commands (gog slides)

New commands:

  • gog slides create — Create new presentation
  • gog slides update — Update slides with markdown content
  • gog slides template — Create from templates (--template flag)

Markdown → Google Slides conversion:

  • Title slides (first H1 becomes slide title)
  • Bullet points
  • Code blocks
  • Bold/italic text

Usage Examples

# Update document with markdown file
gog docs update <docId> --content-file ./document.md --format markdown

# Append to existing document
gog docs update <docId> --content "## New Section\n\nContent here." --append

# Create presentation from markdown
gog slides create "My Presentation" --content-file ./slides.md

# Create from template
gog slides create "Quarterly Report" --template quarterly

Technical Details

UTF-16 Indexing:
Google Docs API uses UTF-16 code units for character positions. This PR correctly handles multi-byte characters (emojis, special characters) by using utf16Len() instead of byte length.

Native Table Insertion:
Tables require multi-step operations:

  1. Insert table structure via InsertTableRequest
  2. Fetch document to retrieve cell indices
  3. Insert text into each cell at calculated positions
  4. Apply header row formatting (bold)

See docs_table_inserter.go for implementation.

Files Changed

File Changes
internal/cmd/docs.go Docs update command + table insertion
internal/cmd/docs_formatter.go Markdown → Docs requests converter
internal/cmd/docs_markdown.go Markdown parser
internal/cmd/docs_markdown_test.go Parser tests
internal/cmd/docs_table_inserter.go Native table insertion (NEW)
internal/cmd/slides.go Slides commands
internal/cmd/slides_formatter.go Markdown → Slides converter
internal/cmd/slides_markdown.go Slides markdown parser
internal/googleapi/slides.go Slides API helpers
internal/googleauth/service.go Added Slides scope

Stats

  • +2,222 lines added
  • -59 lines removed
  • 12 files changed
  • 10 commits

Testing

Tested with real documents including:

  • Docker course documentation (21KB, emojis, diagrams)
  • Research documents with tables
  • Presentation slides with markdown formatting

All inline formatting (bold, italic, code, links) working correctly with UTF-16 indexing.


Built with 🔪 by Jarbas (Gonçalo's AI assistant)

goncaloalves added a commit to goncaloalves/gogcli that referenced this pull request Feb 11, 2026
- Add 'gog slides update' command with markdown formatting
- Create slides_formatter.go for Google Slides API batch updates
- Create slides_markdown.go for markdown parsing (titles, bullets, code)
- Add slides.go with update/create/read operations
- Update googleauth service for Slides scope

Related: PR openclaw#219
goncaloalves and others added 12 commits February 13, 2026 22:44
Phase 1 & 2 complete:
- Markdown parser supporting headings, lists, code blocks, blockquotes, links
- Google Docs API integration for formatting
- --format markdown flag for docs update command
- Heading styles (H1-H6), horizontal rules, list indentation
- Code blocks with monospace font

Pending (Phase 3):
- Inline formatting (bold, italic, inline code) - index calculation issues
- Links - index calculation issues

Usage:
  gog docs update <docId> --content-file ./doc.md --format markdown
- Simplified document generation to avoid index calculation errors
- Fixed ParseInlineFormatting to correctly track positions
- Preserves: headings, code blocks, blockquotes, lists, horizontal rules

Pending: inline formatting (bold, italic, code, links) - indices still need work
- Fixed markdown formatter to use UTF-16 code units instead of UTF-8 bytes
- Added utf16Len() helper function for accurate character counting
- Fixed inline formatting indices (bold, italic, code, links)
- Added empty line handling (MDEmptyLine)
- Successfully tested with Docker course doc (21KB, emojis, diagrams)

This resolves index mismatch errors caused by multi-byte characters like emojis
which are 4 bytes in UTF-8 but 2 code units in UTF-16.
- Add 'gog slides update' command with markdown formatting
- Create slides_formatter.go for Google Slides API batch updates
- Create slides_markdown.go for markdown parsing (titles, bullets, code)
- Add slides.go with update/create/read operations
- Update googleauth service for Slides scope

Related: PR openclaw#219
…tion

- Fixed slides creation to use CreateShape with TEXT_BOX instead of inserting text directly
- Direct text insertion into slides is not supported by Google Slides API
- Added title text box with bold 36pt font
- Added body text box for content (bullets, paragraphs, code)
- Supports markdown formatting (bold, bullets, code blocks)

Tested: Successfully created 20-slide presentation from Docker course outline
@steipete steipete force-pushed the feat/docs-update-command branch from 7bfb533 to d2db0cc Compare February 13, 2026 21:52
@steipete steipete merged commit 7945602 into openclaw:main Feb 13, 2026
1 check passed
@steipete
Copy link
Copy Markdown
Collaborator

Landed via temp rebase onto main.

Thanks @goncaloalves!

klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
* feat: add docs update command for editing Google Docs

* fix: handle document content range correctly for replace

* docs: add Jarbas avatar

* feat(gogcli): add markdown formatting support for Google Docs

Phase 1 & 2 complete:
- Markdown parser supporting headings, lists, code blocks, blockquotes, links
- Google Docs API integration for formatting
- --format markdown flag for docs update command
- Heading styles (H1-H6), horizontal rules, list indentation
- Code blocks with monospace font

Pending (Phase 3):
- Inline formatting (bold, italic, inline code) - index calculation issues
- Links - index calculation issues

Usage:
  gog docs update <docId> --content-file ./doc.md --format markdown

* fix(gogcli): fix inline formatting indices in markdown formatter

- Simplified document generation to avoid index calculation errors
- Fixed ParseInlineFormatting to correctly track positions
- Preserves: headings, code blocks, blockquotes, lists, horizontal rules

Pending: inline formatting (bold, italic, code, links) - indices still need work

* fix(gogcli): use UTF-16 code units for Google Docs API indexing

- Fixed markdown formatter to use UTF-16 code units instead of UTF-8 bytes
- Added utf16Len() helper function for accurate character counting
- Fixed inline formatting indices (bold, italic, code, links)
- Added empty line handling (MDEmptyLine)
- Successfully tested with Docker course doc (21KB, emojis, diagrams)

This resolves index mismatch errors caused by multi-byte characters like emojis
which are 4 bytes in UTF-8 but 2 code units in UTF-16.

* feat(gogcli): add slides commands with markdown support

- Add 'gog slides update' command with markdown formatting
- Create slides_formatter.go for Google Slides API batch updates
- Create slides_markdown.go for markdown parsing (titles, bullets, code)
- Add slides.go with update/create/read operations
- Update googleauth service for Slides scope

Related: PR openclaw#219

* fix(gogcli): use shapes for slides text boxes instead of direct insertion

- Fixed slides creation to use CreateShape with TEXT_BOX instead of inserting text directly
- Direct text insertion into slides is not supported by Google Slides API
- Added title text box with bold 36pt font
- Added body text box for content (bullets, paragraphs, code)
- Supports markdown formatting (bold, bullets, code blocks)

Tested: Successfully created 20-slide presentation from Docker course outline

* feat: add markdown table support (formatted text output)

* feat: implement native Google Docs table insertion with multi-step API

* feat(slides): add --template flag for creating presentations from templates

* fix: stabilize docs/slides markdown + auth flow (openclaw#219) (thanks @goncaloalves)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
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