From d92d511319f5c85efe04b99265748ee56d27503b Mon Sep 17 00:00:00 2001 From: "Jorj X. McKie" Date: Thu, 21 May 2026 08:09:01 -0400 Subject: [PATCH 1/2] Create test_markdown_support.py Tests: * Support of Archive in Document creation * Support of external / internal links --- tests/test_markdown_support.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test_markdown_support.py diff --git a/tests/test_markdown_support.py b/tests/test_markdown_support.py new file mode 100644 index 000000000..1bee3e6ba --- /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(__file__).parent / "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 From 5c3a564020985cd95fdd5313e382efbed8323a73 Mon Sep 17 00:00:00 2001 From: "Jorj X. McKie" Date: Thu, 21 May 2026 09:45:46 -0400 Subject: [PATCH 2/2] Update test_markdown_support.py --- tests/test_markdown_support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_markdown_support.py b/tests/test_markdown_support.py index 1bee3e6ba..53967ff03 100644 --- a/tests/test_markdown_support.py +++ b/tests/test_markdown_support.py @@ -4,7 +4,7 @@ def test_archive_markdown(): """Test Archive support.""" - path = pathlib.Path(__file__).parent / "resources" + 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()