From 6c6121a8497ac70c2520f778dc4d7bcf373c1684 Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Fri, 14 Jan 2022 21:49:11 -0300 Subject: [PATCH] Add PDF generation --- generate.py | 7 +++++++ index.html | 2 +- requirements.txt | 1 + templates/dir.html | 2 +- templates/file.html | 6 ++++-- templates/stylesheet.css | 20 ++++++++++++++++++-- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/generate.py b/generate.py index bfcffa8..a107f58 100755 --- a/generate.py +++ b/generate.py @@ -1,6 +1,7 @@ #!python import os import shutil +import pdfkit from markdown2 import markdown input_ = 'input_files' @@ -44,14 +45,20 @@ for root, dirs, files in os.walk(input_, topdown=True): with open(outfile, 'w') as f: content = markdown(content) + pdf = basename + '.pdf' pretty_name = basename.replace('_', ' ') new_file = render_template(file_template, title=pretty_name, path=outroot.replace('_', ' ') + '/' + pretty_name, + pdf=pdf, content=content) + content += '' + + pdfkit.from_string(content, outroot + '/' + pdf) + f.write(new_file) index_html = '