Different heading levels for siblings, missing heading (parse with python lib) #567

Open
opened 2026-02-16 00:18:17 -05:00 by yindo · 1 comment
Owner

Originally created by @pasha-createdbyhumans on GitHub (Nov 10, 2025).

Describe the bug
PDF book for "Death in Venice" has roman numbering of chapters - from "I" to "V", and after parsing I get the first four as headings with increasing level (from 1 to 4) and the last one "V" as just text, even though by the bounding box you can see they are all centered on page and have the same height of 15 :

          {
            "type": "heading",
            "lvl": 1,
            "value": "I",
            "md": "# I",
            "bBox": {
              "x": 303.07,
              "y": 498.75,
              "w": 5.84,
              "h": 15
            }
...
          {
            "type": "heading",
            "lvl": 2,
            "value": "II",
            "md": "## II",
            "bBox": {
              "x": 300.15,
              "y": 433.5,
              "w": 11.67,
              "h": 15
            }
          },
...
          {
            "type": "heading",
            "lvl": 3,
            "value": "III",
            "md": "### III",
            "bBox": {
              "x": 297.23,
              "y": 554.25,
              "w": 17.51,
              "h": 15
            }
          },
...
          {
            "type": "heading",
            "lvl": 4,
            "value": "IV",
            "md": "#### IV",
            "bBox": {
              "x": 297.66,
              "y": 347.25,
              "w": 16.67,
              "h": 15
            }
          },
...
          {
            "type": "text",
            "value": "V",
            "md": "V",
            "bBox": {
              "x": 300.57,
              "y": 399,
              "w": 10.83,
              "h": 15
            }
          },

Files
Death In Venice - PDF

Job ID
036e399b-f0d6-4749-b6ad-6341a8d79de7

Client:
Please remove untested options:

  • Python Library

Additional context
Copy-pasted init code :

                self.parser = LlamaParse(
                    api_key=self.api_key,
                    result_type="json",
                    parse_mode="parse_page_with_agent",
                    model="openai-gpt-4-1-mini",
                    high_res_ocr=True,
                    system_prompt_append="""
This is a book document. Please:
1. Extract metadata at the beginning (Title, Author, Year Published, ISBN)
2. Preserve chapter headings with appropriate heading levels
3. Preserve section and subsection headings
4. Maintain paragraph structure
5. Identify front matter (preface, foreword, introduction, prologue)
6. Identify back matter (epilogue, afterword, appendix, index, glossary)
7. Preserve any special formatting (quotes, emphasis)
""",
                    verbose=True,
                )

...

json_dicts = self.parser.get_json(tmp_filepath)

Originally created by @pasha-createdbyhumans on GitHub (Nov 10, 2025). **Describe the bug** PDF book for "Death in Venice" has roman numbering of chapters - from "I" to "V", and after parsing I get the first four as headings with increasing level (from 1 to 4) and the last one "V" as just text, even though by the bounding box you can see they are all centered on page and have the same height of 15 : ``` { "type": "heading", "lvl": 1, "value": "I", "md": "# I", "bBox": { "x": 303.07, "y": 498.75, "w": 5.84, "h": 15 } ... { "type": "heading", "lvl": 2, "value": "II", "md": "## II", "bBox": { "x": 300.15, "y": 433.5, "w": 11.67, "h": 15 } }, ... { "type": "heading", "lvl": 3, "value": "III", "md": "### III", "bBox": { "x": 297.23, "y": 554.25, "w": 17.51, "h": 15 } }, ... { "type": "heading", "lvl": 4, "value": "IV", "md": "#### IV", "bBox": { "x": 297.66, "y": 347.25, "w": 16.67, "h": 15 } }, ... { "type": "text", "value": "V", "md": "V", "bBox": { "x": 300.57, "y": 399, "w": 10.83, "h": 15 } }, ``` **Files** [Death In Venice - PDF](https://drive.google.com/file/d/1Q_J9ZYGqz91oGdl6wGwJz3U4P-RVWl98/view?usp=sharing) **Job ID** 036e399b-f0d6-4749-b6ad-6341a8d79de7 **Client:** Please remove untested options: - Python Library **Additional context** Copy-pasted init code : ``` self.parser = LlamaParse( api_key=self.api_key, result_type="json", parse_mode="parse_page_with_agent", model="openai-gpt-4-1-mini", high_res_ocr=True, system_prompt_append=""" This is a book document. Please: 1. Extract metadata at the beginning (Title, Author, Year Published, ISBN) 2. Preserve chapter headings with appropriate heading levels 3. Preserve section and subsection headings 4. Maintain paragraph structure 5. Identify front matter (preface, foreword, introduction, prologue) 6. Identify back matter (epilogue, afterword, appendix, index, glossary) 7. Preserve any special formatting (quotes, emphasis) """, verbose=True, ) ... json_dicts = self.parser.get_json(tmp_filepath) ```
yindo added the bug label 2026-02-16 00:18:17 -05:00
Author
Owner

@pasha-createdbyhumans commented on GitHub (Nov 11, 2025):

Here is output for premium_mode=True, exact init code :

                self.parser = LlamaParse(
                    api_key=self.api_key,
                    result_type="structured", #"json",
                    ignore_errors=False,
                    split_by_page=False,
                    continuous_mode=True,
                    premium_mode=True,
                )

, the chapter "V" is still missing, and you can s how it is not present in "md" section while visible in "text" section :

       "page": 47,
        "text": "\n\n    V\n\n    During his fourth week at the Lido Gustav von Aschenbach made several...
        "md": "During his fourth week at the Lido Gustav von Aschenbach made several
        "images": [],
        "charts": [],
        "items": [
          {
            "type": "text",
            "value": "During his fourth week at the Lido Gustav von Aschenbach made several...
            "md": "During his fourth week at the Lido Gustav von Aschenbach made several...
          },
...
@pasha-createdbyhumans commented on GitHub (Nov 11, 2025): Here is output for premium_mode=True, exact init code : ``` self.parser = LlamaParse( api_key=self.api_key, result_type="structured", #"json", ignore_errors=False, split_by_page=False, continuous_mode=True, premium_mode=True, ) ``` , the chapter "V" is still missing, and you can s how it is not present in "md" section while visible in "text" section : ``` "page": 47, "text": "\n\n V\n\n During his fourth week at the Lido Gustav von Aschenbach made several... "md": "During his fourth week at the Lido Gustav von Aschenbach made several "images": [], "charts": [], "items": [ { "type": "text", "value": "During his fourth week at the Lido Gustav von Aschenbach made several... "md": "During his fourth week at the Lido Gustav von Aschenbach made several... }, ... ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#567