From a072017525be0a0685b210edc2326a2d71906a1d Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 10 May 2017 20:52:00 +0100 Subject: [PATCH] Add page breaks when needed --- md_pdf/assets/static/style.scss | 9 +++++++++ md_pdf/build/template.py | 1 + 2 files changed, 10 insertions(+) diff --git a/md_pdf/assets/static/style.scss b/md_pdf/assets/static/style.scss index 2295a1b..904d81f 100644 --- a/md_pdf/assets/static/style.scss +++ b/md_pdf/assets/static/style.scss @@ -27,12 +27,21 @@ body.content { img { margin-top: $image-spacing; width: 100%; + page-break-after: avoid; } p.caption { margin: 1px 5px $image-spacing; padding: 0; font-style: italic; + page-break-before: avoid; } + .references-title { + page-break-after: avoid; + } + + h1, h2, h3, h4, h5, h6 { + page-break-after: avoid; + } } diff --git a/md_pdf/build/template.py b/md_pdf/build/template.py index b74a1d3..1802e41 100644 --- a/md_pdf/build/template.py +++ b/md_pdf/build/template.py @@ -12,6 +12,7 @@ def fix_references_title(content, config): reference_element = soup.find('div', class_='references') if reference_element is not None: title = soup.new_tag('h1') + title['class'] = 'references-title' title.string = "References" reference_element.insert_before(title) return soup.prettify()