diff --git a/custom_syadmin/build_from_notion.py b/custom_syadmin/build_from_notion.py index 0c90ac6..4632637 100644 --- a/custom_syadmin/build_from_notion.py +++ b/custom_syadmin/build_from_notion.py @@ -120,7 +120,7 @@ def get_record_text(post, level=0): 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) + text = re.sub('`(bib|session|topic):([a-zA-Z0-9-]+)`', r'![](\1:\2)', text) return text @@ -130,9 +130,11 @@ def yaml_home(record): return """--- title: > %s +draft: %s has_topics: %s ---\n\n""" % ( record["name"], + "false" if record.get("published", True) else "true", "[ %s ]" % ', '.join(topics), ) @@ -143,9 +145,11 @@ def yaml_topic(record): return """--- title: > %s +draft: %s has_sessions: %s ---\n\n""" % ( record["name"], + "false" if record.get("published", True) else "true", "[ %s ]" % ', '.join(sessions), ) @@ -155,8 +159,10 @@ def yaml_default(record): return """--- title: > %s +draft: %s ---\n\n""" % ( - record["name"] + record["name"], + "false" if record.get("published", True) else "true" ) @@ -184,7 +190,7 @@ def notion_to_md(id, filepath=None, yaml_func=None): # print(page_data) if filepath: os.umask(0) - with open(os.open(filepath, os.O_CREAT | os.O_WRONLY, 0o777), 'w', encoding="utf-8") as f: + with open(os.open(filepath, os.O_CREAT | os.O_WRONLY, 0o777), 'w') as f: f.write(page_content) return page_data