From 243ccc46411a727ec4e20e787ccf6f4fae32bb71 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 25 May 2017 20:07:38 +0100 Subject: [PATCH] Add wordcount to footer --- md_pdf/assets/static/style.scss | 1 + md_pdf/assets/templates/footer-template.html | 4 ++++ md_pdf/assets/templates/header-template.html | 7 +++++++ md_pdf/build/context.py | 5 +++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/md_pdf/assets/static/style.scss b/md_pdf/assets/static/style.scss index 522df91..ddfdefe 100644 --- a/md_pdf/assets/static/style.scss +++ b/md_pdf/assets/static/style.scss @@ -55,6 +55,7 @@ body.footer, body.header { td { text-align: center; + width: 33%; } } } diff --git a/md_pdf/assets/templates/footer-template.html b/md_pdf/assets/templates/footer-template.html index fdf7715..ceabfa5 100644 --- a/md_pdf/assets/templates/footer-template.html +++ b/md_pdf/assets/templates/footer-template.html @@ -6,9 +6,13 @@ + +
Page of + Total Words: {{ word_count }} +
diff --git a/md_pdf/assets/templates/header-template.html b/md_pdf/assets/templates/header-template.html index 91e760b..3f8c9a8 100644 --- a/md_pdf/assets/templates/header-template.html +++ b/md_pdf/assets/templates/header-template.html @@ -4,6 +4,13 @@ + + + + + + +
diff --git a/md_pdf/build/context.py b/md_pdf/build/context.py index 0d14468..e380d42 100644 --- a/md_pdf/build/context.py +++ b/md_pdf/build/context.py @@ -11,6 +11,7 @@ EXTRA_CONTEXT = { def get_context(config, content): context = config['context'].copy() context['title'] = config['title'] - context = dict(context, **EXTRA_CONTEXT) - context['word_count'] = word_count(content) + context = dict(context, **EXTRA_CONTEXT, **{ + 'word_count': word_count(content) + }) return context