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

Fixed Notion pages mention bug and added function to get them #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guilherme-abcam
Copy link

A sample database with fields filled with Notion pages mentions
Screenshot_1836

The result when trying to get the value
Screenshot_1840


The result with this fix
Screenshot_1841

And the new function to get the mentioned pages in a PageBlock array.
Screenshot_1842

@jamalex
Copy link
Owner

jamalex commented Jan 1, 2020

This is fantastic, thanks for the contribution!

There are several types of structures (page mentions, reminders, tags of people, and I think a few more) that aren't currently handled by the Markdown <> Notion conversions. The tricky part is that we want it to be bidirectional, so that if the same markdown is set back onto a field, it restores the original Notion data structures internally. For page mentions, this should be straightforward enough, as we can parse the markdown link, see that it's a page reference, and turn it back into a page reference in Notion's internal structure. For things like reminders and people references, the Markdown representation is less clear.

Given the tight coupling between the parsing and conversion, and the need to go in both directions, I'm thinking it would be better to handle this conversion (the _convert_notion_to_python part of your code) within the notion_to_markdown function. And then we'll need to add handling in markdown_to_notion to catch the special link type and turn it back into the appropriate Notion structure.

Would you be interested to take a stab at that?

for format in part[1]:
if "p" in format:
page = self._client.get_block(format[1])
val[i] = (["[" + page.icon + " " + page.title + "](" + page.get_browseable_url() + ")"])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes a TypeError if the page doesn't have an icon or title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions and suggestions welcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants