Render cover
This commit is contained in:
parent
6075d540d8
commit
ca8b97bdb0
2 changed files with 13 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
import click
|
import click
|
||||||
from md_pdf.build.md import read_files
|
from md_pdf.build.md import read_files
|
||||||
from md_pdf.build.pandoc import build_document
|
from md_pdf.build.pandoc import build_document
|
||||||
|
from md_pdf.build.cover import render_cover
|
||||||
|
|
||||||
|
|
||||||
@click.command('build', short_help="Build document")
|
@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):
|
def cli(in_files, bibliography, output):
|
||||||
data = read_files(in_files)
|
data = read_files(in_files)
|
||||||
doc = build_document(data, bibliography)
|
doc = build_document(data, bibliography)
|
||||||
print(doc)
|
render_cover()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
from jinja2 import Template
|
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())
|
template = Template(f.read())
|
||||||
with open("cover.html", "w") as f:
|
with open(OUTPUT_COVER_FILE, "w") as f:
|
||||||
cover = template.render(context)
|
cover = template.render(context)
|
||||||
f.write(cover)
|
f.write(cover)
|
||||||
return cover
|
return cover
|
||||||
|
|
Reference in a new issue