From de3d758005c78aea0130cdd2e9fc9edc67745a10 Mon Sep 17 00:00:00 2001 From: Akbar Rahman Date: Tue, 2 Jan 2024 04:01:56 +0000 Subject: [PATCH] render articles with jinja --- gronk.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gronk.py b/gronk.py index 89b42fc..f3c498f 100755 --- a/gronk.py +++ b/gronk.py @@ -256,17 +256,23 @@ def render_markdown_file(input_filepath): write markdown file to args.output_dir in html, return list of tuple of output filepath, frontmatter post """ - print(f"render_markdown_file({input_filepath})") with open(input_filepath, encoding='utf-8') as file_pointer: content = frontmatter.load(file_pointer).content properties = FILEMAP.get(input_filepath) - # TODO pandoc no longer handles template due to metadata passing issues, use jinja to fill in the metadata html = render_markdown(content) + html = JINJA_TEMPLATE_ARTICLE.render( + license=LICENSE, + content=html, + lecture_slides=properties.get("lecture_slides"), + lecture_notes=properties.get("lecture_notes"), + uuid=properties.get("uuid"), + tags=properties.get("tags"), + author=properties.get("author"), + title=properties.get("title")) - with open(properties['dst_path']['html'], 'w+', encoding='utf-8') as file_pointer: - file_pointer.write(html) + properties['dst_path']['html'].write_text(html) def render_plaintext_file(input_filepath):