md2gdocs
md2gdocs is a simple library and CLI for uploading Markdown content to Google Drive/Docs.
Google Authentication
To use this tool, you will need to set up a project in the Google Cloud Console and configure oauth for your project. You will also need to enable the Google Drive API in your project.
This is a bit complicated, and outside the scope of this README. If you are not already familiar with Google Cloud and/or oauth, expect to spend some time figuring this out. If you have no idea what any of this means, this tool may not be practical for you to use. I cannot help you with this. Please don't ask. Sorry.
See Configure the OAuth consent screen and choose scopes
as a starting point. If you don't have a Google Workspace, you will need to choose External for the user type, and
explicitly add specific "test" users who are authorized to authenticate via oauth. You will also need to add the scope
https://www.googleapis.com/auth/drive to the oauth consent configuration.
You will then need to download the client credentials and save them in the path specified in the configuration file
(see below), which defaults to ~/.local/etc/auth/google/client_credentials.json.
The first time you run md2gdocs a browser window will open, and ask you to authenticate with your Google account.
This will store a token in the path specified in the configuration file (by default
~/.local/etc/auth/google/md2gdocs_token.json) so that you will not need to authenticate every time you run the code.
Command Line
For command-line use, it is recommended to install using pipx: pipx install md2gdocs.
Once installed, you can call it from the command line by running md2gdocs /path/to/markdown_file.md.
Library
To use in your python program, first install the library with pip install md2gdocs or using your preferred package
manager. Then:
import md2gdocs
md2gdocs.convert_and_upload("/path/to/markdown_file.md")
Creating a New File
Markdown frontmatter is used to specify the Google Drive file name and ID, e.g.
---
title: My First Markdown File
---
# Hello, Markdown!
This is a paragraph in my markdown file.
In the above example, md2gdocs will use My First Markdown File as the Google Drive file name.
The title field is mandatory in the Markdown frontmatter, otherwise md2gdocs won't know what to name
the file in Google Drive.
The first time you upload a file to Google Drive, md2gdocs will update the YAML frontmatter of the Markdown file with
the Google Drive ID of the file it created:
---
title: My First Markdown File
gdrive_id: xxxxxxxxxxxxxxxxxx
---
# Hello, Markdown!
This is a paragraph in my markdown file.
If you remove the gdrive_id from your Markdown file, then the next time you run md2gdocs, a completely new Google
Drive file will be created.
Updating a File
On subsequent uploads, md2gdocs will replace the name and contents of the existing Google Doc with the contents of
the Markdown file, provided you have not removed the gdrive_id from the Markdown frontmatter. This will create a new
revision of the Google Doc.
Note that any comments in the Google doc will be lost on update, so be sure to address or copy any comments before updating.
Configuration
Configuration options can be specified in ~/.local/etc/md2gdocs/md2gdocs.yml as follows:
google:
oauth:
client_credentials: /Users/wryfi/.local/etc/auth/google/client_credentials.json
server_port: 9999
token: /Users/wryfi/.local/etc/auth/google/md2gdocs_token.json
log:
level: info
markdown:
extensions: []
Metadata
Release files for md2gdocs 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| md2gdocs-1.0.0.tar.gz | 4.5 kB | Without provenance | Details for md2gdocs-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| md2gdocs-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for md2gdocs-1.0.0-py3-none-any.whl |
Total release size: 9.7 kB
Release files / md2gdocs-1.0.0.tar.gz
| Download URL | md2gdocs-1.0.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbfab975322699f3b1172704d0edcac2d38ab8030a2ea64d446605c4a719dedb
|
|
BLAKE2b-256 checksum How to use checksums |
b24665ed597ac64e1297390e65dacbbeec00e8cc08eb48f1b82fb72895d375bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.13.2 CPython/3.12.2 Darwin/23.4.0
|
Release files / md2gdocs-1.0.0-py3-none-any.whl
| Download URL | md2gdocs-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ed186798129635e53f684975172dbe0e3c3745926a5afb4c50b376b4a9a4250
|
|
BLAKE2b-256 checksum How to use checksums |
a70b567f4aa0976d84b809c020754b57d9bf17974b3d07789dfb651a7f85764e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.13.2 CPython/3.12.2 Darwin/23.4.0
|
Security for md2gdocs 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.