Skip to content

fix: render figures with drawn labels as one image (0.8.1) - #15

Merged
MichaelD-42 merged 1 commit into
mainfrom
fix/figure-zones-0.8.1
Nov 25, 2026
Merged

MichaelD-42 merged 1 commit into
mainfrom
fix/figure-zones-0.8.1

Conversation

@MichaelD-42

Copy link
Copy Markdown
Owner

Problem

A PDF figure built from tiny drawings, bitmaps and several chart clusters, labelled in a smaller font than the body, came out as partial crops plus loose label paragraphs and empty tables. An unnumbered caption below a figure stayed a body paragraph.

Fix

  • lib/figures.py: _merge_figure_zones joins a figure's parts (kept regions, tiny clusters, bitmaps) and its label lines (font < 0.9 x body size) into one region. Parts and labels join within 24 pt vertically. Flow lines (body text, [...] marker lines, captions, numbered headings) bound the region and its padding. The region renders as one crop ("zone": true), its labels become figure_text, inner bitmaps get no element, and inner tables become table_in_figure.
  • Unnumbered caption fallback in find_caption_line: a one-line title directly below an image is its caption.
  • gates.py: new warning figure_without_image for a figure_labels cluster (4+ label lines, no drawing or bitmap) that no image covers. The grader prompt and docs mention it.
  • Asset naming and the md-tree format are unchanged.

Verification

  • New synthetic tests in tests/test_figure_zones.py (no customer material).
  • Full suite: 1020 passed. 1 failure, test_audit_fixes.py::TestQueueInitSafety::test_a_dot_name_input_deletes_nothing, fails on main too (local Python 3.14).
  • LLM-free extraction eval unchanged (text 0.991, headings 0.833, tables 1.0).
  • Checked locally on a confidential customer document: the broken figure is now one image with its caption, and requirement marker lines stay their own paragraphs. A downstream importer run confirmed it.
  • Not run: /eval-grader after the small agents/grader.md addition.

🤖 Generated with Claude Code

A figure built from tiny drawings, bitmaps and several chart clusters,
labelled in a smaller font than the body, came out as partial crops plus
loose label paragraphs and empty tables. lib/figures.py now merges such
parts and their label lines into one region, bounded by flow lines
(body text, [...] marker lines, captions, numbered headings), renders it
as one crop and drops the labels and inner tables from the text flow.

An unnumbered one-line title directly below a figure is its caption.
A cluster of labels with no image is recorded as figure_labels and
gates.py warns figure_without_image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@MichaelD-42
MichaelD-42 merged commit a31ba92 into main Nov 25, 2026
6 checks passed
@MichaelD-42
MichaelD-42 deleted the fix/figure-zones-0.8.1 branch November 25, 2026 18:13
@MichaelD-42 MichaelD-42 added bug Something isn't working enhancement New feature or request documentation Improvements or additions to documentation labels Nov 25, 2026
MichaelD-42 added a commit that referenced this pull request Nov 29, 2026
fix: render figures with drawn labels as one image (0.8.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant