Skip to content

Feature request / Question #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BenBlumer opened this issue May 10, 2020 · 2 comments
Open

Feature request / Question #141

BenBlumer opened this issue May 10, 2020 · 2 comments

Comments

@BenBlumer
Copy link

Does anyone have a suggested strategy for programatically exporting notion docs as markdown?

I've seen the md2notion package for going the opposite direction. Is there a way to pull it directly from Notion?

If I have to, I can parse and convert each block on a page, but given that it's built into Notion's "Export" menu, there must be a better way.

@dragonwocky
Copy link

@BenBlumer I used the concept from #91 to write my own notion-to-html renderer that makes parsing blocks significantly easier (see renderer.py and build.py - the latter implements the former but also performs a number of unrelated tasks).
The renderer has been built in a way that a markdown implementation could theoretically be added without too much difficulty - the only problem is that there are a lot of block types that are unsupported by markdown, and a few which notion-py doesn't seem to know how to handle (renderer.md).

Notion's "export to markdown" does have the same limitations, excluding user/date mentions which do work (I am yet to implement these successfully, but I believe they are possible). Most embeds/tables etc. that don't translate across to markdown are just exported as links.

I've only just finished building this for use with my own website, if I get some time I'll extract it into its own repo and extend it a bit more.

If as you were talking about in the other issue you opened you can get directly accessing the notion export-to-markdown endpoint that's probably quicker/simpler, but hey, I saw this and couldn't help replying.

@natikgadzhi
Copy link
Contributor

@BenBlumer, I've actually just made Notoma — a CLI tool to export Notion -> Markdown, based on this library. Let me know if it helps (or sucks)?

I'll add images, embeds, and links to other pages support tomorrow and release a new version on pypi. The way it's built is iterating through page blocks, and it expects a database as a list of pages to export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants