feat(docs): support --replace --markdown --tab whole-tab re-render (#595)#625
Merged
Conversation
…penclaw#595) Drive's markdown converter is whole-document-only, so `docs write --replace --markdown --tab=<tab>` previously errored. Implement the workaround at the gogcli layer by wiping the targeted tab's body via `DeleteContentRange` and re-rendering the markdown locally through the same Docs `batchUpdate` path used by `--append --markdown`. Other tabs are left untouched. Empty-tab handling skips the delete step (Docs rejects ranges where end <= start), and a tab-not-found error is surfaced before any batchUpdate is issued.
b48aa90 to
fcdc05f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #595.
gog docs write <docId> --replace --markdown --tab=<tab>previously errored with--markdown with --replace does not support --tab (Drive's markdown converter operates on entire documents). Drive's converter is whole-document-only, but the Docs API itself happily targets tab ranges, so the whole-tab re-render is a small workaround at the gogcli layer:documents.getwithincludeTabsContent=true.endIndex > 2), issue aDeleteContentRangecovering[1, endIndex-1]with the tab ID.insertDocsMarkdownAthelper at index1with the tab ID — the same path that already powers--append --markdown --tab(including bullets, tables, code, images, and inline formatting).No new dependencies; reuses
ParseMarkdown/MarkdownToDocsRequests/TableInserter/insertImagesIntoDocs, all of which already accept a tab ID. Empty tabs skip the delete step; unknown--tabvalues still produce the standard tab-not-found error before any batchUpdate.Test plan
go build ./...clean.go test ./...clean (43.8s oninternal/cmd).internal/cmd/docs_write_markdown_tab_test.go:TestDocsWrite_MarkdownReplaceWithTab— asserts a non-empty tab producesDeleteContentRange{Range:{Start:1,End:19,TabId:t.second}}followed byInsertText{Location:{Index:1,TabId:t.second}}+ formatting requests all carrying the tab ID; verifies Drive is never called.TestDocsWrite_MarkdownReplaceWithTab_EmptyTab— asserts the delete step is skipped when the tab body is empty (Docs API rejects end <= start ranges).TestDocsWrite_MarkdownReplaceWithTab_TabNotFound— asserts an unknown tab title produces the standardtab not found: "Missing"error before any batchUpdate is issued.CHANGELOG.mdupdated under 0.17.1 Added.docs/docs-editing.mdupdated with the new tab-rerender example.Notes for reviewer
--markdownwas not changed; its existing wording (requires --replace or --append) is still accurate.--markdown with --replace does not support --tab (...)was removed since the case it described is now supported.🤖 Generated with Claude Code