docs_write
Write markdown or plain text into a Google Doc using its existing styles. Insert, append, or replace content based on anchors, headings, or specific text matches.
Instructions
Write markdown (or plain text) into a Google Doc, typed in the document's own styles. Modes: append, prepend, replace_document (overwrites the body), insert_after / insert_before / replace_text (relative to an exact anchor snippet; replace_text with empty text deletes it), replace_section (anchor = heading text; replaces everything under that heading up to the next heading of the same or higher level). Markdown: headings, bold/italic/code/links, bullet/numbered/task lists with nesting, quotes, code blocks, tables, rules, images (), and \pagebreak on its own line. The result says whether Drive has the change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc | Yes | Google Docs URL or document id. | |
| mode | Yes | ||
| text | No | Content as literal plain text (no markdown interpretation). Use this or markdown. | |
| anchor | No | insert_after / insert_before / replace_text: exact text already in the document (case-insensitive unless matchCase). replace_section: the heading text. | |
| account | No | Which signed-in Google account to use: an index as in /u/N/ URLs (0 = first account) or an email address. Omit for the browser default. Use this for documents owned by a second (e.g. school) account. | |
| asBlock | No | insert_after / insert_before: put even a one-paragraph payload in its own new paragraph instead of splicing it inline. | |
| markdown | No | Content as markdown. Use this or text. | |
| matchCase | No | Anchor matching is case-sensitive. Default false. | |
| occurrence | No | Which match of the anchor: 1 = first (default), 2 = second, -1 = last. |