From ca8b97bdb0ba0abae14638abaf53728616449584 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 28 Mar 2017 21:31:42 +0100 Subject: [PATCH] Render cover --- md_pdf/build/cli.py | 4 +++- md_pdf/build/cover.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/md_pdf/build/cli.py b/md_pdf/build/cli.py index 29f70c9..1bf8e1d 100644 --- a/md_pdf/build/cli.py +++ b/md_pdf/build/cli.py @@ -1,6 +1,7 @@ import click from md_pdf.build.md import read_files from md_pdf.build.pandoc import build_document +from md_pdf.build.cover import render_cover @click.command('build', short_help="Build document") @@ -10,5 +11,6 @@ from md_pdf.build.pandoc import build_document def cli(in_files, bibliography, output): data = read_files(in_files) doc = build_document(data, bibliography) - print(doc) + render_cover() + diff --git a/md_pdf/build/cover.py b/md_pdf/build/cover.py index 13e1899..c799d01 100644 --- a/md_pdf/build/cover.py +++ b/md_pdf/build/cover.py @@ -1,9 +1,16 @@ from jinja2 import Template +from md_pdf.utils import PROJECT_DIR +import os -def render_cover(context): - with open("cover-template.html") as f: + +COVER_TEMPLATE = os.path.join(PROJECT_DIR, 'assets', 'cover-template.html') +OUTPUT_COVER_FILE = os.path.join(PROJECT_DIR, 'assets', 'cover.html') + + +def render_cover(context={}): + with open(COVER_TEMPLATE) as f: template = Template(f.read()) - with open("cover.html", "w") as f: + with open(OUTPUT_COVER_FILE, "w") as f: cover = template.render(context) f.write(cover) return cover