diff --git a/_scripts/generate.py b/_scripts/generate.py index 3ecad4c..8bde3a5 100644 --- a/_scripts/generate.py +++ b/_scripts/generate.py @@ -17,6 +17,7 @@ EXTENSIONS = [ ".org.txt", ] +MIN_HIDDEN_HEADLINE_LEVEL = 2 def load_all(top_dir_relative): top = os.path.abspath(top_dir_relative) @@ -92,7 +93,7 @@ def main(src_top, dest_top): 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))) + f.write(as_document(render(main_headline, doc, headlineLevel=0))) files_generated += 1 else: logging.error("Cannot render document from id: {}. {} headlines {} related".format( @@ -105,7 +106,7 @@ def main(src_top, dest_top): endpath = os.path.join(dest_top, headline.id + ".node.html") with open(endpath, "wt") as f: - f.write(as_document(render(headline, doc))) + f.write(as_document(render(headline, doc, headlineLevel=0))) files_generated += 1 logging.info("Generated {} files".format(files_generated)) @@ -200,7 +201,7 @@ def render(headline, doc): content = [] render_tree(dom, content) for child in headline.children: - content.append(render(child, doc)) + content.append(render(child, doc, headlineLevel=headlineLevel+1)) if headline.state is None: state = "" @@ -211,16 +212,22 @@ def render(headline, doc): todo_state = "todo" else: todo_state = "done" + + display_state = 'collapsed' + if headlineLevel < MIN_HIDDEN_HEADLINE_LEVEL: + display_state = 'expanded' + return f""" -