Generate file-level nodes if OrgDoc has ID.

This is for compatibility with Org-Roam v2.
This commit is contained in:
Sergio Martínez Portela 2022-05-07 13:15:30 +02:00
parent 2c6d54d9ed
commit 1fd1827821

View File

@ -83,6 +83,24 @@ def main(src_top, dest_top):
# print("Skip:", relpath)
continue
if doc.id is not None:
topHeadlines = doc.getTopHeadlines()
if ((len(topHeadlines) == 1 and related is None)
or (len(topHeadlines) == 2 and related is not None)):
endpath = os.path.join(dest_top, doc.id + ".node.html")
main_headline = [h for h in topHeadlines if h != related][0]
with open(endpath, "wt") as f:
f.write(as_document(render(main_headline, doc)))
files_generated += 1
else:
logging.error("Cannot render document from id: {}. {} headlines {} related".format(
relpath,
len(topHeadlines),
'with' if related is not None else 'without'
))
for headline in headlines:
endpath = os.path.join(dest_top, headline.id + ".node.html")