PyMuPDF
PyMuPDF copied to clipboard
Stories: Ordered list count broken with nested unordered list
Description of the bug
When you use an unordered list (<ul>) inside an ordered list (<ol>) item, you get a broken count where it will count the items in the <ul> as part of the <ol>.
Example:
How to reproduce the bug
Here's a small reproducer:
import fitz
HTML = """
<p>Count is fine:</p>
<ol>
<li>Lorem
<ol>
<li>Sub Lorem</li>
<li>Sub Lorem</li>
</ol>
</li>
<li>Lorem</li>
<li>Lorem</li>
</ol>
<p>Broken count:</p>
<ol>
<li>Lorem
<ul>
<li>Sub Lorem</li>
<li>Sub Lorem</li>
</ul>
</li>
<li>Lorem</li>
<li>Lorem</li>
</ol>
"""
MEDIABOX = fitz.paper_rect("A4")
WHERE = MEDIABOX + (36, 36, -36, -36)
story = fitz.Story(html=HTML)
writer = fitz.DocumentWriter("output.pdf")
more = 1
while more:
device = writer.begin_page(MEDIABOX)
more, _ = story.place(WHERE)
story.draw(device)
writer.end_page()
writer.close()
PyMuPDF version
1.24.9
Operating system
Linux
Python version
3.12
This was reported upstream at https://bugs.ghostscript.com/show_bug.cgi?id=707989
Fixed in PyMuPDF-1.24.14.