Convert Markdown to Google Docs API requests
Low maintenance activity. Last release 12 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and release cadence.
$
pip install gravitas-md2gdocsgravitas-md2gdocs
Convert Markdown to Google Docs API requests.
Installation
pip install gravitas-md2gdocs
To use the Google API helper functions:
pip install gravitas-md2gdocs[google]
Usage
Basic: Get API Requests
from gravitas_md2gdocs import to_requests
markdown = """
# My Document
This is **bold** and *italic* text.
- Bullet one
- Bullet two
> A blockquote
"""
requests = to_requests(markdown)
# Use with your own Google Docs API client
docs_service.documents().batchUpdate(
documentId=doc_id,
body={'requests': requests}
).execute()
Insert at a Specific Position
requests = to_requests(markdown, start_index=50)
Helper Functions (requires gravitas-md2gdocs[google])
from gravitas_md2gdocs import append, replace, insert_at, replace_range
# Append to end of document
append(docs_service, doc_id, "## New Section\n\nMore content")
# Replace entire document
replace(docs_service, doc_id, new_markdown)
# Insert at specific position
insert_at(docs_service, doc_id, "**inserted**", index=25)
# Replace a range (characters 10-50)
replace_range(docs_service, doc_id, "**replacement**", start=10, end=50)
Supported Markdown
| Syntax | Example |
|---|---|
| Headers | # H1 through ###### H6 |
| Bold | **bold** or __bold__ |
| Italic | *italic* or |