diff --git a/md_pdf/assets/cover-template.html b/md_pdf/assets/cover-template.html index e4bc72e..8675240 100644 --- a/md_pdf/assets/cover-template.html +++ b/md_pdf/assets/cover-template.html @@ -5,13 +5,16 @@

{{ title }}

-

{{ subtitle }}

+ {% if subtitle %} +

{{ subtitle }}

+ {% endif %} + {% if student_number %} -
Student Number: {{ student_number }}
+

Student Number: {{ student_number }}

{% endif %} {% if turnitin_number %} -
TurnItIn Number: {{ turnitin_number }}
+

TurnItIn Number: {{ turnitin_number }}

{% endif %} diff --git a/md_pdf/assets/style.css b/md_pdf/assets/style.css index 9da2ea9..5c81e76 100644 --- a/md_pdf/assets/style.css +++ b/md_pdf/assets/style.css @@ -4,6 +4,6 @@ body.cover { } body.cover h1 { - font-size: 72px; + font-size: 48px; padding-top: 400px; } diff --git a/md_pdf/build/__init__.py b/md_pdf/build/__init__.py index 3aebf19..abd99ab 100644 --- a/md_pdf/build/__init__.py +++ b/md_pdf/build/__init__.py @@ -11,5 +11,5 @@ def build(config): if 'html' in config['output_formats']: output_html(doc, os.path.abspath(config['output_dir'])) if 'pdf' in config['output_formats']: - render_cover(config['context']) + render_cover(config) export_pdf(doc, config) diff --git a/md_pdf/build/cover.py b/md_pdf/build/cover.py index 70fbab9..c73cb10 100644 --- a/md_pdf/build/cover.py +++ b/md_pdf/build/cover.py @@ -1,13 +1,15 @@ from jinja2 import Template -from md_pdf.consts import PROJECT_DIR +from md_pdf.consts import ASSET_DIR import os -COVER_TEMPLATE = os.path.join(PROJECT_DIR, 'assets', 'cover-template.html') -OUTPUT_COVER_FILE = os.path.join(PROJECT_DIR, 'assets', 'cover.html') +COVER_TEMPLATE = os.path.join(ASSET_DIR, 'cover-template.html') +OUTPUT_COVER_FILE = os.path.join(ASSET_DIR, 'cover.html') -def render_cover(context={}): +def render_cover(config): + context = config['context'].copy() + context['title'] = config['title'] with open(COVER_TEMPLATE) as f: template = Template(f.read()) with open(OUTPUT_COVER_FILE, "w") as f: diff --git a/md_pdf/build/pdf.py b/md_pdf/build/pdf.py index c921283..a35fb90 100644 --- a/md_pdf/build/pdf.py +++ b/md_pdf/build/pdf.py @@ -25,7 +25,7 @@ PDF_OPTIONS = { def export_pdf(content, config): PDF_OPTIONS['title'] = config.get('title', 'Output') - PDF_OPTIONS['replace'] = list(config['context'].items()) + PDF_OPTIONS['replace'] = [(key, str(value)) for key, value in config['context'].items()] return pdfkit.from_string( content, diff --git a/test-files/mdp.yml b/test-files/mdp.yml index 6118dd9..9f1ad47 100644 --- a/test-files/mdp.yml +++ b/test-files/mdp.yml @@ -9,4 +9,6 @@ bibliography: context: foo: bar bar: foo -title: test + student_number: 123456 + turnitin_number: 789123 +title: test title diff --git a/test-files/test.md b/test-files/test.md index 8ae0569..043968d 100644 --- a/test-files/test.md +++ b/test-files/test.md @@ -1 +1 @@ -# Test +# Test content