← Back to Pull requests

fix(pdf): merge drop caps into the paragraph they open #5527

Open
unknown opened this pull request with 249 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 22, 2026 23:47 UTC
Author

<!-- Thank you for contributing to Docling! -->

Issue resolved by this Pull Request:
Resolves #3883

A drop cap came out as its own one-letter block between paragraphs, or as "R ealized" when it sat in the paragraph's own cluster. PageAssembleModel now handles it on clusters before the elements are built. A drop cap is one uppercase-letter cell at least 2x the page's median line height (single-character cells are left out of that median). It only joins a line that starts lowercase, sits just right of it, has its top aligned with the drop cap's top and its baseline above the drop cap's baseline. A drop cap in its own cluster moves its cell into the target cluster and the bbox is widened. A drop cap already inside the cluster is joined to its word. Only TEXT, SECTION_HEADER and LIST_ITEM clusters are considered, so captions, footnotes, page furniture, code and formulas are never merged.

Checklist:

  • Documentation has been updated, if necessary.

  • Examples have been added, if necessary.

  • Tests have been added, if necessary.
  • Review evidence:

    Before: a drop-cap "R" was exported as a standalone paragraph, or as "R ealized" when inside the cluster. After: both give "Realized through a combination of..." in one paragraph.

    New TestDropCap tests in tests/test_page_assemble_model.py use synthetic clusters:

  • a drop-cap cluster is merged into the next paragraph, with cells, bbox and element count checked

  • a drop cap inside the paragraph's own cluster is joined without a space

  • a body-size letter, a letter in another column, a letter below the paragraph and a caption letter all stay separate
  • Ran:

  • pytest tests/test_page_assemble_model.py -q -k DropCap fails before the change and passes after

  • pytest tests/test_page_assemble_model.py -q passes

  • ruff check and ruff format --check on the two changed files pass
  • Not run: the full test suite, and the fuerea_digital_transformation_2026.pdf from the issue. No reference data changed.

    Diff: 249 lines (+186 / -63) across 3 files Reviewer: github-actions[bot] Review duration: 12m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.39) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 249 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.330
    Real PR Conversation Timeline
    1 comments
    "Review active on #5527"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.0% (MEDIUM) · Higher = larger blast radius
    39.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.2% · Safe to merge
    22.2%