A renderer and uploader for Markdown files to notion
Project description
Markdown to Notion-py
An importer for Markdown files to Notion.so using notion-py
It provides these features over Notion's Markdown importer:
- Picking a Notion.so page to upload to (instead of them all uploading to the root)
- Code fences keep their original language (or as close as we can match it)
- Code fences are formatted properly
- Inline HTML is preserved
- Markdown frontmatter is preserved
- Local image references will be uploaded from relative URLs
- Image alts are loaded as captions instead of as
TextBlock
s - Among other improvements...
If you dislike the way this package implements a specific Markdown to Notion conversion or you need extra functionality (like uploading your images to personal Cloud hosting or something), you can subclass NotionPyRenderer
(a BaseRenderer
for mistletoe
) and change it or hook its behavior.
Limitations
- Currently does not support tables/
CollectionViewBlocks
Usage with Python 3.6+
-
pip install md2notion
-
From the command link you can run
python -m md2notion.upload [token_v2] [page-url] [...markdown_path_globs]
-
OR In your Python file:
from notion.client import NotionClient
from md2notion.upload import upload
# Follow the instructions at https://github.com/jamalex/notion-py#quickstart to setup Notion.py
client = NotionClient(token_v2="<token_v2>")
page = client.get_block("https://www.notion.so/myorg/Test-c0d20a71c0944985ae96e661ccc99821")
with open("TestMarkdown.md", "r", encoding="utf-8") as mdFile:
newPage = notionPage.children.add_new(PageBlock, title="TestMarkdown Upload")
upload(mdFile, newPage) #Appends the converted contents of TestMarkdown.md to newPage
Contributing
See CONTRIBUTING.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file md2notion-0.1.0.tar.gz
.
File metadata
- Download URL: md2notion-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceeeafed771207ae7fac5a74658c7cd3eaded1b3a00015bde999e25c58322012 |
|
MD5 | f9d78dcb3cc5471bc565ffaf90f11a13 |
|
BLAKE2b-256 | 11c8aa82d9bc263cc5eae70b996317480d9cbcdab233ee2defd40aa1817b8f3e |
File details
Details for the file md2notion-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: md2notion-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7645471c647546d089d4ebb1cdb42a95ba8dd99b35b291052bf13f9d2038eff |
|
MD5 | e7a2fde61666d0a79dabbc7b226bb665 |
|
BLAKE2b-256 | 624df28f4e6afc1c124f7825a9ade2ffd98a7d5a2ba4c1466305478abfc735d0 |