diff --git a/tests/test_markdown_support.py b/tests/test_markdown_support.py new file mode 100644 index 000000000..53967ff03 --- /dev/null +++ b/tests/test_markdown_support.py @@ -0,0 +1,34 @@ +import pymupdf +import pathlib + + +def test_archive_markdown(): + """Test Archive support.""" + path = pathlib.Path() / "resources" + md = """![](nur-ruhig.jpg)\n**A referenced image.**""" + md_doc = pymupdf.open(stream=md.encode(), filetype="md", archive=path.name) + pdfdata = md_doc.convert_to_pdf() + doc = pymupdf.open(stream=pdfdata) + page = doc[0] + images = page.get_image_info() + assert len(images) == 1 + +def test_archive_links(): + """Create an internal and an external link and confirm + that they are correctly converted to PDF links.""" + md = """Some text containing an external [link](http://www.google.com) to Google. + Now an internal link to a header in this document: [Some Header](#some-header). The header is here: + + ## Some Header + + Some text following the header. + """ + md_doc = pymupdf.open(stream=md.encode(), filetype="md") + pdfdata = md_doc.convert_to_pdf() + doc = pymupdf.open(stream=pdfdata) + page = doc[0] + links=page.get_links() + assert len(links) == 2 + assert links[0]["uri"] == "http://www.google.com" + assert links[0]["kind"] == pymupdf.LINK_URI + assert links[1]["kind"] == pymupdf.LINK_GOTO