add published status; handle internal session/ topic links

This commit is contained in:
Sean Dockray 2020-06-07 23:50:53 +10:00
parent 1a0e3a8bb6
commit b0dc74872d
1 changed files with 9 additions and 3 deletions

View File

@ -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