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
Hashes for md2notion-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7645471c647546d089d4ebb1cdb42a95ba8dd99b35b291052bf13f9d2038eff |
|
MD5 | e7a2fde61666d0a79dabbc7b226bb665 |
|
BLAKE2b-256 | 624df28f4e6afc1c124f7825a9ade2ffd98a7d5a2ba4c1466305478abfc735d0 |