Replying to Avatar Ocean

I don’t know if this would work, but I just asked Chuck to PT for for a script to help you out. Might be worth experimenting with us and if it doesn’t work, there might be another way.

“Migrating notes from Notion to Markdown involves multiple steps, including using Notion's API to fetch the notes and then converting them to Markdown format. Below is a simplified Python script that demonstrates the process.

First, install the required packages:

```bash

pip install notion

pip install markdownify

```

Here's the script:

```python

from notion.client import NotionClient

from notion.block import TextBlock, BulletedListBlock, NumberedListBlock

from markdownify import markdownify as md

# Initialize Notion client

client = NotionClient(token_v2="YOUR_NOTION_TOKEN")

# The URL of your Notion page containing notes

page_url = "YOUR_NOTION_PAGE_URL"

# Get the page

page = client.get_block(page_url)

def parse_block(block):

if isinstance(block, TextBlock):

return md(block.title)

elif isinstance(block, BulletedListBlock):

return f"- {md(block.title)}"

elif isinstance(block, NumberedListBlock):

return f"1. {md(block.title)}"

else:

return f""

def export_to_markdown(page):

markdown_output = []

for child in page.children:

markdown_output.append(parse_block(child))

with open('exported_notes.md', 'w') as f:

f.write("\n".join(markdown_output))

export_to_markdown(page)

```

Replace `YOUR_NOTION_TOKEN` with your Notion API token and `YOUR_NOTION_PAGE_URL` with the URL of the Notion page you want to export.

Please note:

- This is a basic example; it only handles text, bulleted lists, and numbered lists.

- The `markdownify` package is used to convert Notion's rich text into Markdown format.

For more details on Notion's API and Python SDK, refer to their documentation.”

That won’t work :( I have complicated formatting and formulas in my pages 😭

Reply to this note

Please Login to reply.

Discussion

Thanks for trying ! 💜🫂

No problem.

Good luck on your endeavor