Skip to main content

A renderer and uploader for Markdown files to notion

Project description

twitter twitter

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 TextBlocks
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md2notion-0.1.0.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

md2notion-0.1.0-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page