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

I added TOC block and make inline math showing in a block's title #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions notion/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ class ColumnBlock(Block):

_type = "column"

class TableOfContentsBlock(Block):

_type = "table_of_contents"


class BasicBlock(Block):

Expand All @@ -477,6 +481,27 @@ def convert_to_type(self, new_type):

def _str_fields(self):
return super()._str_fields() + ["title"]

title_list = field_map(
["properties", "title"],
python_to_api=lambda x: [[x]],
api_to_python=lambda x: x,
)

def _get_title(self):
text=""
for list in self.title_list:
if list[0] == "⁍":
text+=list[1][0][1]
else:
text+=list[0]
return text
@property
def title(self):
try:
return self._get_title()
except:
pass


class TodoBlock(BasicBlock):
Expand Down