handle nested lists
This commit is contained in:
parent
bbb1fa88e9
commit
1a0e3a8bb6
|
@ -94,7 +94,7 @@ def hugo(hugo_site_path, dest, hugo_environment='gitea', base_url=None):
|
|||
hugo_output = cmd([HUGO_PATH, '-e', hugo_environment, '-d', dest, '--noTimes'], cwd=hugo_site_path, env=env)
|
||||
|
||||
|
||||
def get_record_text(post):
|
||||
def get_record_text(post, level=0):
|
||||
""" Generates the markdown text of a Notion page
|
||||
see: # https://github.com/brentbaum/brentbaum-notion-publishing/blob/master/notion/get_posts.py """
|
||||
text = ""
|
||||
|
@ -111,10 +111,15 @@ def get_record_text(post):
|
|||
text += f"![{caption}]({child.source})\n"
|
||||
elif child.type == "divider":
|
||||
text += "---"
|
||||
elif child.type == "bulleted_list":
|
||||
prefix = prefixes.get(child.type, "")
|
||||
text += ' ' * (level * 4) + prefix + child.title.encode('utf-8').decode('utf-8') + "\n\n"
|
||||
if len(child.children):
|
||||
text += get_record_text(child, level + 1)
|
||||
else:
|
||||
prefix = prefixes.get(child.type, "")
|
||||
text += prefix + child.title.encode('utf-8').decode('utf-8') + "\n\n"
|
||||
|
||||
|
||||
text = re.sub('`bib:([a-zA-Z0-9-]+)`', r'![](bib:\1)', text)
|
||||
return text
|
||||
|
||||
|
|
Loading…
Reference in New Issue