From 498117584a7a73f2d857eb517e8e0a9f148c61ff Mon Sep 17 00:00:00 2001 From: Ed Ward Date: Wed, 31 Jul 2019 14:18:07 +0200 Subject: [PATCH] Include images in the automated PDF --- README.md | 1 + build.py | 16 ++++++++++------ page-template.html | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 00fdfa35..e9ab27cb 100644 --- a/README.md +++ b/README.md @@ -126,3 +126,4 @@ The `build.py` script that builds the manual accepts the following options: - '-q', or '--quiet', to suppress all output (overrides -v) - '-d', or '--devmode', to add content to pages to help developers debug them (link, file name, URL) +- '-n', or '--nopdf', to prevent the build script from generate a PDF from the content diff --git a/build.py b/build.py index e656fd19..75a13f18 100755 --- a/build.py +++ b/build.py @@ -454,11 +454,12 @@ temp.close() onepage = onepage.replace('{{page.bootstrap_path}}', global_bootstrap_path) onepage = onepage.replace('{{page.page_title}}', global_page_title) -# Same as above, but for the PDF version -temp = open(global_pdf_template) -pdfpage = temp.read() -temp.close() -pdfpage = pdfpage.replace('{{page.page_title}}', global_page_title) +if not nopdf: + # Same as above, but for the PDF version + temp = open(global_pdf_template) + pdfpage = temp.read() + temp.close() + pdfpage = pdfpage.replace('{{page.page_title}}', global_page_title) # Parse out the master document's structure into a dictionary list fileStruct = GetFileStructure() @@ -614,7 +615,8 @@ for header in fileStruct: # Set up the actual page from the template onepage = onepage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}') - pdfpage = pdfpage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}') + if not nopdf: + pdfpage = pdfpage.replace('{{ content }}', oph + '\n' + opcontent + '\n{{ content }}') # ----- Normal version ----- @@ -681,6 +683,8 @@ if not nopdf: pdfpageFile = open(global_site_dir + 'pdf.html', 'w') pdfpage = pdfpage.replace('{% tree %}', opsidebar) # create the TOC pdfpage = pdfpage.replace('{{ content }}', '') # cleans up the last spaceholder + pdfpage = pdfpage.replace('src="/images/', 'src="images/') # makes images links relative + pdfpage = pdfpage.replace('url(\'/images/', 'url(\'images/') # CSS images links relative pdfpageFile.write(pdfpage) pdfpageFile.close() diff --git a/page-template.html b/page-template.html index bc4a1007..026d0be9 100644 --- a/page-template.html +++ b/page-template.html @@ -27,7 +27,7 @@ - +