fix: Keep formula clusters also when empty (#1970)

Keep formula clusters also when empty

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
Christoph Auer 2025-07-22 17:02:12 +02:00 committed by GitHub
parent 90a7cc4bdd
commit 67441ca418
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -267,9 +267,14 @@ class LayoutPostprocessor:
# Initial cell assignment # Initial cell assignment
clusters = self._assign_cells_to_clusters(clusters) clusters = self._assign_cells_to_clusters(clusters)
# Remove clusters with no cells (if keep_empty_clusters is False) # Remove clusters with no cells (if keep_empty_clusters is False),
# but always keep clusters with label DocItemLabel.FORMULA
if not self.options.keep_empty_clusters: if not self.options.keep_empty_clusters:
clusters = [cluster for cluster in clusters if cluster.cells] clusters = [
cluster
for cluster in clusters
if cluster.cells or cluster.label == DocItemLabel.FORMULA
]
# Handle orphaned cells # Handle orphaned cells
unassigned = self._find_unassigned_cells(clusters) unassigned = self._find_unassigned_cells(clusters)