From f745ee5f0b624ffe8bba7ca9115f1f34f7093557 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 10 May 2017 21:42:03 +0100 Subject: [PATCH] Enable internal links --- md_pdf/build/pdf.py | 1 + md_pdf/build/template.py | 4 ++-- test-files/1intro.md | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/md_pdf/build/pdf.py b/md_pdf/build/pdf.py index 60c6b4b..cc6dbbb 100644 --- a/md_pdf/build/pdf.py +++ b/md_pdf/build/pdf.py @@ -16,6 +16,7 @@ FOOTER_FILE = os.path.join(TEMPLATES_DIR, 'footer.html') PDF_OPTIONS = { "quiet": "", "no-pdf-compression": "", + "enable-internal-links": "", "header-html": HEADER_FILE, "footer-html": FOOTER_FILE, diff --git a/md_pdf/build/template.py b/md_pdf/build/template.py index 1802e41..15803b2 100644 --- a/md_pdf/build/template.py +++ b/md_pdf/build/template.py @@ -21,8 +21,8 @@ def fix_references_title(content, config): def add_base_tag(doc, config): logger.debug("Adding Base Tag...") soup = BeautifulSoup(doc, 'html.parser') - base_tag = soup.new_tag('base', href=os.path.abspath(config['output_dir'])) - soup.head.insert(0, base_tag) + for img in soup.findAll('img'): + img['src'] = os.path.abspath(img['src']) return soup.prettify() diff --git a/test-files/1intro.md b/test-files/1intro.md index d26cb43..f9d0d18 100644 --- a/test-files/1intro.md +++ b/test-files/1intro.md @@ -3,3 +3,5 @@ _Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ante purus, scelerisque sed pulvinar eget, suscipit feugiat augue. Cras quis quam ac dui aliquam rhoncus eu id diam. Cras dapibus vel nunc in finibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla a lacinia nibh. Aenean finibus mauris et est euismod aliquam. Curabitur dictum nulla quis turpis fringilla vestibulum at eget ligula. Donec et ultricies massa, ut volutpat neque. Praesent elementum ultrices urna at finibus. Nunc risus mi, porta sed eros sit amet, sagittis sollicitudin velit. Nulla a felis in tellus gravida pretium sit amet eget libero. Donec aliquet ac est semper molestie._ __Curabitur arcu velit, faucibus sed condimentum vitae, consectetur a lectus. Fusce a cursus magna. Nam vel posuere erat, in congue purus. Aliquam aliquet eu leo vel cursus. Vestibulum mattis est ac diam finibus, in aliquet erat iaculis. Phasellus est quam, rutrum a tempus non, vehicula vitae tellus. Nam nec leo consectetur, aliquam lorem eget, dignissim arcu. Phasellus vitae convallis urna, ac aliquet purus. Vivamus nisl mauris, volutpat quis pretium non, fringilla non dui. Pellentesque velit justo, pretium a porta nec, varius ac lacus.__ + +[reference](#test-image)