MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_markdown

Function test_markdown

tests/test_tables.py:302–330  ·  view source on GitHub ↗

Confirm correct markdown output.

()

Source from the content-addressed store, hash-verified

300
301
302def test_markdown():
303 """Confirm correct markdown output."""
304 filename = os.path.join(scriptdir, "resources", "strict-yes-no.pdf")
305 doc = pymupdf.open(filename)
306 page = doc[0]
307 tab = page.find_tables(strategy="lines_strict")[0]
308 if pymupdf.mupdf_version_tuple < (1, 26, 3):
309 md_expected = textwrap.dedent(''&#x27;
310 |Header1|Header2|Header3|
311 |---|---|---|
312 |Col11<br>Col12|~~Col21~~<br>~~Col22~~|Col31<br>Col32<br>Col33|
313 |Col13|~~Col23~~|Col34<br>Col35|
314 |Col14|~~Col24~~|Col36|
315 |Col15|~~Col25~~<br>~~Col26~~||
316
317 ''&#x27;).lstrip()
318 else:
319 md_expected = (
320 "|Header1|Header2|Header3|\n"
321 "|---|---|---|\n"
322 "|Col11<br>Col12|Col21<br>Col22|Col31<br>Col32<br>Col33|\n"
323 "|Col13|Col23|Col34<br>Col35|\n"
324 "|Col14|Col24|Col36|\n"
325 "|Col15|Col25<br>Col26||\n\n"
326 )
327
328
329 md = tab.to_markdown()
330 assert md == md_expected, f'Incorrect md:\n{textwrap.indent(md, " ")}'
331
332
333def test_paths_param():

Callers

nothing calls this directly

Calls 1

to_markdownMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…