PyMuPDF icon indicating copy to clipboard operation
PyMuPDF copied to clipboard

Stories: Ordered list count broken with nested unordered list

Open rafaelmardojai opened this issue 1 year ago • 1 comments

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: Captura desde 2024-08-27 16-55-56

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

rafaelmardojai avatar Aug 27 '24 21:08 rafaelmardojai

This was reported upstream at https://bugs.ghostscript.com/show_bug.cgi?id=707989

sebras avatar Aug 28 '24 06:08 sebras

Fixed in PyMuPDF-1.24.14.