Prune empty conditional list paragraphs after fill #61

Merged
parkerhdavis merged 2 commits from prune-empty-conditional-paragraphs into main 2026-05-06 12:09:43 -06:00
parkerhdavis commented 2026-05-06 12:09:37 -06:00 (Migrated from github.com)

Summary

  • When a lily-cond: SDT resolves to empty, the rewritten zero-width bookmark used to leave a blank-bulleted paragraph behind in numbered lists (e.g., a stray (c) between filled rows in the HIPAA template). A new prune_empty_conditional_paragraphs post-pass runs after update_sdt_v2 and drops any <w:p> whose only lily-cond: bookmark has no surrounding visible content (no non-whitespace text, no tabs/breaks/drawings/fields). Mixed paragraphs and intentionally blank spacing paragraphs are preserved.
  • Mirrored in scripts/docx_utils.py for parity with the Python template tooling.
  • Bundles the one-shot migration script that produced the HIPAA template's bold names + (a)/(b)/(c) list (the change in Lily-Carelaw that motivated this prune feature).

Test plan

  • make test — 93 Rust tests pass, including six new test_prune_* cases (positive prune, mixed-content kept, lily: bookmark kept, tab/break kept, multiple consecutive pruned, whitespace-no-conditional kept).
  • make lint — no new warnings; clippy clean for changed code.
  • Python parity verified against the same six scenarios.
  • End-to-end render of the migrated HIPAA template with Secondary filled and Tertiary empty: list flows (a) → (b) JANE DOE; → (c) → (d) with the empty Tertiary paragraph removed.
## Summary - When a `lily-cond:` SDT resolves to empty, the rewritten zero-width bookmark used to leave a blank-bulleted paragraph behind in numbered lists (e.g., a stray `(c)` between filled rows in the HIPAA template). A new `prune_empty_conditional_paragraphs` post-pass runs after `update_sdt_v2` and drops any `<w:p>` whose only `lily-cond:` bookmark has no surrounding visible content (no non-whitespace text, no tabs/breaks/drawings/fields). Mixed paragraphs and intentionally blank spacing paragraphs are preserved. - Mirrored in `scripts/docx_utils.py` for parity with the Python template tooling. - Bundles the one-shot migration script that produced the HIPAA template's bold names + (a)/(b)/(c) list (the change in Lily-Carelaw that motivated this prune feature). ## Test plan - [x] `make test` — 93 Rust tests pass, including six new `test_prune_*` cases (positive prune, mixed-content kept, `lily:` bookmark kept, tab/break kept, multiple consecutive pruned, whitespace-no-conditional kept). - [x] `make lint` — no new warnings; clippy clean for changed code. - [x] Python parity verified against the same six scenarios. - [x] End-to-end render of the migrated HIPAA template with Secondary filled and Tertiary empty: list flows `(a) → (b) JANE DOE; → (c) → (d)` with the empty Tertiary paragraph removed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
parker/lily!61
No description provided.