diff --git a/md_pdf/assets/static/style.scss b/md_pdf/assets/static/style.scss index d158fa2..419f740 100644 --- a/md_pdf/assets/static/style.scss +++ b/md_pdf/assets/static/style.scss @@ -16,7 +16,22 @@ body.cover { } } -body, html { + +$image_spacing: 30px; + +body.content { line-height: 1.5; font-size: 12px; + + img { + width: 100%; + margin-top: $image_spacing + } + + p.caption { + margin: 0 5px $image_spacing; + padding: 0; + font-style: italic; + } + } diff --git a/md_pdf/build/template.py b/md_pdf/build/template.py index 835162d..7533106 100644 --- a/md_pdf/build/template.py +++ b/md_pdf/build/template.py @@ -25,6 +25,13 @@ def add_base_tag(doc, config): return soup.prettify() +def add_body_class(doc, config): + logger.debug("Adding Body Class...") + soup = BeautifulSoup(doc, 'html.parser') + soup.body['class'] = 'content' + return soup.prettify() + + def render_template(html, config): logger.debug("Rendering Template...") template = Template(html) @@ -36,9 +43,9 @@ def parse_template(doc, config): for parser in [ fix_references_title, add_base_tag, - render_template + add_body_class, ]: parsed_doc = parser(parsed_doc, config) - return parsed_doc + return render_template(parsed_doc, config) diff --git a/test-files/test-image.png b/test-files/test-image.png index a91d8ec..05e2bc8 100644 Binary files a/test-files/test-image.png and b/test-files/test-image.png differ