Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tests/test_markdown_support.py
Original file line number Diff line number Diff line change
@@ -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
Loading