From ee4855a3ecbeabc6bb9cbeca33e1f35238f12fee Mon Sep 17 00:00:00 2001 From: Eunchan Cho Date: Sun, 1 Nov 2020 02:17:09 +0900 Subject: [PATCH] ADD TOC and ADD Inline Math Support Feature --- notion/block.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/notion/block.py b/notion/block.py index 6420c26..b585edd 100644 --- a/notion/block.py +++ b/notion/block.py @@ -453,6 +453,10 @@ class ColumnBlock(Block): _type = "column" +class TableOfContentsBlock(Block): + + _type = "table_of_contents" + class BasicBlock(Block): @@ -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):