flexablelib 2.0.7__tar.gz → 2.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flexablelib-2.0.7 → flexablelib-2.0.8}/CHANGELOG.md +9 -0
- {flexablelib-2.0.7/flexablelib.egg-info → flexablelib-2.0.8}/PKG-INFO +1 -1
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/merges.py +61 -5
- {flexablelib-2.0.7 → flexablelib-2.0.8/flexablelib.egg-info}/PKG-INFO +1 -1
- {flexablelib-2.0.7 → flexablelib-2.0.8}/package.json +1 -1
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_merges.py +50 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/LICENSE +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/MANIFEST.in +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/README.md +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/__init__.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/_speedups.c +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/_width_tables.h +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/cells.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/colors.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/columns.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/fast.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/options.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/readers.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/style_compositions.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/table.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/table_strings.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/text_width.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/utils.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib/writers.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib.egg-info/SOURCES.txt +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib.egg-info/requires.txt +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/setup.cfg +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/setup.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_cells.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_columns.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_excel.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_features.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_issues.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_readme_examples.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_styles.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_text_width.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tests/test_upstream_issues.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tools/benchmark.py +0 -0
- {flexablelib-2.0.7 → flexablelib-2.0.8}/tools/generate_width_tables.py +0 -0
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.0.8] - 2026-10-28
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Synthetic caps for multi-column merges clamp their horizontal run to the
|
|
9
|
+
merge's column span (no H bleeding into neighbour columns). Covers
|
|
10
|
+
column-only styles such as `grid_eheader` / `round_edges` / `pretty_columns`.
|
|
11
|
+
- Junction repair skips invisible/spacer vertical glyphs, so styles like
|
|
12
|
+
`simple` no longer pick up stray `┴`/`┼` on header and end rules.
|
|
13
|
+
|
|
5
14
|
## [2.0.7] - 2026-10-28
|
|
6
15
|
|
|
7
16
|
### Fixed
|
|
@@ -271,6 +271,11 @@ def _is_h(ch: str) -> bool:
|
|
|
271
271
|
return ch in _H_CHARS
|
|
272
272
|
|
|
273
273
|
|
|
274
|
+
def _visible_vertical(ch: str) -> bool:
|
|
275
|
+
"""True when a style's vertical glyph is a real column rule, not a spacer."""
|
|
276
|
+
return bool(ch) and not ch.isspace()
|
|
277
|
+
|
|
278
|
+
|
|
274
279
|
def _char_at(line: str, index: int) -> str:
|
|
275
280
|
if index < 0 or index >= visible_width(line):
|
|
276
281
|
return ''
|
|
@@ -283,12 +288,12 @@ def _junction_positions(layout, composition):
|
|
|
283
288
|
if v is None:
|
|
284
289
|
return []
|
|
285
290
|
out = []
|
|
286
|
-
if layout.spans and v.left:
|
|
291
|
+
if layout.spans and _visible_vertical(v.left):
|
|
287
292
|
out.append((layout.spans[0][0] - len(v.left), v.left))
|
|
288
293
|
for sep_x in layout.separators:
|
|
289
|
-
if v.middle:
|
|
294
|
+
if _visible_vertical(v.middle):
|
|
290
295
|
out.append((sep_x, v.middle))
|
|
291
|
-
if layout.spans and v.right:
|
|
296
|
+
if layout.spans and _visible_vertical(v.right):
|
|
292
297
|
out.append((layout.spans[-1][1], v.right))
|
|
293
298
|
return out
|
|
294
299
|
|
|
@@ -400,6 +405,48 @@ def _build_rule_line(layout, composition, column_widths, hidden, rule=None):
|
|
|
400
405
|
return left + center + right
|
|
401
406
|
|
|
402
407
|
|
|
408
|
+
def _clamp_rule_to_h_ranges(line, layout, composition, h_ranges, filler=' '):
|
|
409
|
+
"""
|
|
410
|
+
Keep horizontal runs only inside ``h_ranges`` (merge content spans).
|
|
411
|
+
|
|
412
|
+
Synthetic caps are inserted for multi-column merges; without clamping, the
|
|
413
|
+
full-width rule bleeds H into neighbour columns that have no reason for a
|
|
414
|
+
row edge. Outside the ranges, content is blanked and junctions fall back to
|
|
415
|
+
the style's vertical glyph so column rules continue cleanly. Callers that
|
|
416
|
+
also need taller merges punched through should run ``_blank_crossings``
|
|
417
|
+
*after* this so restored verticals inside those merges stay erased.
|
|
418
|
+
"""
|
|
419
|
+
if not h_ranges:
|
|
420
|
+
return line
|
|
421
|
+
ranges = sorted((int(a), int(b)) for a, b in h_ranges if b > a)
|
|
422
|
+
if not ranges:
|
|
423
|
+
return line
|
|
424
|
+
# Merge overlapping / abutting ranges.
|
|
425
|
+
merged = [list(ranges[0])]
|
|
426
|
+
for a, b in ranges[1:]:
|
|
427
|
+
if a <= merged[-1][1]:
|
|
428
|
+
merged[-1][1] = max(merged[-1][1], b)
|
|
429
|
+
else:
|
|
430
|
+
merged.append([a, b])
|
|
431
|
+
ranges = [(a, b) for a, b in merged]
|
|
432
|
+
|
|
433
|
+
def in_ranges(x):
|
|
434
|
+
return any(a <= x < b for a, b in ranges)
|
|
435
|
+
|
|
436
|
+
rewritten = line
|
|
437
|
+
for start, end in layout.spans:
|
|
438
|
+
if any(not (end <= a or start >= b) for a, b in ranges):
|
|
439
|
+
continue
|
|
440
|
+
if end > start:
|
|
441
|
+
rewritten = _repaint(rewritten, start, end, filler * (end - start))
|
|
442
|
+
|
|
443
|
+
for x, v_glyph in _junction_positions(layout, composition):
|
|
444
|
+
if in_ranges(x):
|
|
445
|
+
continue
|
|
446
|
+
rewritten = _repaint(rewritten, x, x + 1, v_glyph)
|
|
447
|
+
return rewritten
|
|
448
|
+
|
|
449
|
+
|
|
403
450
|
def _looks_like_rule(line: str, h_glyph: str = None) -> bool:
|
|
404
451
|
"""True only for real separator lines, not cell text that contains '-'."""
|
|
405
452
|
if not line:
|
|
@@ -574,21 +621,25 @@ def apply(lines, row_line_map, regions, column_widths, composition,
|
|
|
574
621
|
if region.first_row > 0:
|
|
575
622
|
g = region.first_row - 1
|
|
576
623
|
plan = gap_plans.setdefault(
|
|
577
|
-
g, {'s': set(), 'n': set(), 'at': min(target_lines)
|
|
624
|
+
g, {'s': set(), 'n': set(), 'at': min(target_lines),
|
|
625
|
+
'h': []}
|
|
578
626
|
)
|
|
579
627
|
plan['s'] |= set(inner_seps)
|
|
580
628
|
plan['at'] = min(plan['at'], min(target_lines))
|
|
629
|
+
plan.setdefault('h', []).append((start, end))
|
|
581
630
|
# Cap below: gap after last_row (unless last table row — end
|
|
582
631
|
# line is repaired in pass 3).
|
|
583
632
|
max_row = max(row_line_map) if row_line_map else region.last_row
|
|
584
633
|
if region.last_row < max_row:
|
|
585
634
|
g = region.last_row
|
|
586
635
|
plan = gap_plans.setdefault(
|
|
587
|
-
g, {'s': set(), 'n': set(), 'at': max(target_lines) + 1
|
|
636
|
+
g, {'s': set(), 'n': set(), 'at': max(target_lines) + 1,
|
|
637
|
+
'h': []}
|
|
588
638
|
)
|
|
589
639
|
plan['n'] |= set(inner_seps)
|
|
590
640
|
plan['at'] = min(plan.get('at', max(target_lines) + 1),
|
|
591
641
|
max(target_lines) + 1)
|
|
642
|
+
plan.setdefault('h', []).append((start, end))
|
|
592
643
|
|
|
593
644
|
# --- Pass 2: repair junctions on body rules touched by vertical blanks ---
|
|
594
645
|
if h_glyph:
|
|
@@ -658,6 +709,11 @@ def apply(lines, row_line_map, regions, column_widths, composition,
|
|
|
658
709
|
)
|
|
659
710
|
if rule is None:
|
|
660
711
|
continue
|
|
712
|
+
# H only across the merges that asked for this cap — not the
|
|
713
|
+
# whole table — then punch through taller crossings.
|
|
714
|
+
rule = _clamp_rule_to_h_ranges(
|
|
715
|
+
rule, layout, composition, plan.get('h') or []
|
|
716
|
+
)
|
|
661
717
|
rule = _blank_crossings(rule, g)
|
|
662
718
|
rule = _repair_rule_junctions(
|
|
663
719
|
rule, layout, composition, syn_h,
|
|
@@ -782,3 +782,53 @@ def test_crossing_vertical_merge_keeps_edge_when_cap_inserted():
|
|
|
782
782
|
# Body synthetic rule: starts with │ (edge through ALL) not ├.
|
|
783
783
|
if '┬' in line or '┴' in line:
|
|
784
784
|
assert line.startswith('│'), line
|
|
785
|
+
|
|
786
|
+
def test_synthetic_cap_h_stays_inside_merge_column_span():
|
|
787
|
+
"""Synthetic caps must not draw H into columns outside the merge span."""
|
|
788
|
+
table = Table(style_name='grid_eheader')
|
|
789
|
+
for c in range(4):
|
|
790
|
+
table.add_column(f'C{c}', [f'r{r}c{c}' for r in range(4)])
|
|
791
|
+
table.merge_cells(0, 0, last_row=2, value='V')
|
|
792
|
+
table.merge_cells(0, 1, last_column=2, value='HSPAN')
|
|
793
|
+
|
|
794
|
+
lines = str(table).splitlines()
|
|
795
|
+
hspan_i = next(i for i, line in enumerate(lines) if 'HSPAN' in line)
|
|
796
|
+
cap = lines[hspan_i + 1]
|
|
797
|
+
assert _looks_like_rule_line(cap), cap
|
|
798
|
+
# Bleed looked like: | +------+------+------+
|
|
799
|
+
# Clamped looks like: | +------+------+ |
|
|
800
|
+
assert not (cap.rstrip().endswith('+') or cap.endswith('------+')), cap
|
|
801
|
+
assert '+ |' in cap or cap.endswith(' |'), cap
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
def test_synthetic_cap_does_not_bleed_through_unrelated_column():
|
|
805
|
+
"""Item column next to a V|N merge must not carry a horizontal run."""
|
|
806
|
+
table = Table(style_name='round_edges')
|
|
807
|
+
table.add_column('Cat', [''] * 6)
|
|
808
|
+
table.add_column('Item', [f'i{r}' for r in range(6)])
|
|
809
|
+
table.add_column('V', list(range(6)))
|
|
810
|
+
table.add_column('N', [f'n{r}' for r in range(6)])
|
|
811
|
+
table.merge_cells(0, 0, last_row=5, value='ALL')
|
|
812
|
+
table.merge_cells(1, 2, last_row=3, last_column=3, value='BOX')
|
|
813
|
+
|
|
814
|
+
lines = str(table).splitlines()
|
|
815
|
+
for line in lines:
|
|
816
|
+
if not _looks_like_rule_line(line):
|
|
817
|
+
continue
|
|
818
|
+
if '═' in line or line.startswith('╭') or line.startswith('╰'):
|
|
819
|
+
continue
|
|
820
|
+
if '┬' in line or '┴' in line:
|
|
821
|
+
assert '├──────┼' not in line, line
|
|
822
|
+
# Desired shape: │ │ ├───┴────┤
|
|
823
|
+
assert '│ ├' in line or '│ │' in line, line
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
def test_invisible_vertical_style_keeps_plain_dash_rules():
|
|
827
|
+
"""Styles with spacer verticals (simple) must not gain ┴/┼ from merges."""
|
|
828
|
+
table = Table(style_name='simple')
|
|
829
|
+
for c in range(6):
|
|
830
|
+
table.add_column(f'C{c}', [f'r{r}c{c}' for r in range(4)])
|
|
831
|
+
table.merge_cells(0, 0, last_row=1, last_column=1, value='#0,0')
|
|
832
|
+
table.merge_cells(0, 4, last_row=1, last_column=5, value='#0,4')
|
|
833
|
+
rendered = str(table)
|
|
834
|
+
assert '┴' not in rendered and '┼' not in rendered and '┬' not in rendered, rendered
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|