From 85f52065bc8a3de1e1bdb14def513ac3d97ef75a Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 10 May 2017 17:41:49 +0100 Subject: [PATCH] Better syntax for parsers --- md_pdf/build/template.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/md_pdf/build/template.py b/md_pdf/build/template.py index c50d7b9..835162d 100644 --- a/md_pdf/build/template.py +++ b/md_pdf/build/template.py @@ -5,7 +5,8 @@ import logging logger = logging.getLogger(__file__) -def fix_references_title(content): + +def fix_references_title(content, config): logger.debug("Adding Reference Title...") soup = BeautifulSoup(content, 'html.parser') reference_element = soup.find('div', class_='references') @@ -31,8 +32,13 @@ def render_template(html, config): def parse_template(doc, config): - doc = fix_references_title(doc) - doc = add_base_tag(doc, config) - return render_template(doc, config) + parsed_doc = doc + for parser in [ + fix_references_title, + add_base_tag, + render_template + ]: + parsed_doc = parser(parsed_doc, config) + return parsed_doc