Skip to content
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

JsonToMd().page2md fails when block["children"] is None #6

Open
kapicic opened this issue Nov 20, 2024 · 1 comment
Open

JsonToMd().page2md fails when block["children"] is None #6

kapicic opened this issue Nov 20, 2024 · 1 comment

Comments

@kapicic
Copy link

kapicic commented Nov 20, 2024

Description

When calling JsonToMd().page2md on a list of block where at least one block is missing the children key, the conversion fails.

Steps to reproduce:

from notion_client.client import Client as NotionClient
from notion2markdown.json2md import JsonToMd

client = NotionClient(auth=...)
blocks = client.blocks.children.list(page_id)
page_content = JsonToMd().page2md(blocks) # fails KeyError("children")
@kapicic
Copy link
Author

kapicic commented Nov 20, 2024

The fix is easy, instead of doing value["children"] inside of JsonToMd, just do value.get("children", [])

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

1 participant