flexablelib 2.0.7__tar.gz → 2.0.9__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.
Files changed (43) hide show
  1. {flexablelib-2.0.7 → flexablelib-2.0.9}/CHANGELOG.md +16 -0
  2. {flexablelib-2.0.7/flexablelib.egg-info → flexablelib-2.0.9}/PKG-INFO +2 -2
  3. {flexablelib-2.0.7 → flexablelib-2.0.9}/README.md +1 -1
  4. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/merges.py +61 -5
  5. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/style_compositions.py +22 -0
  6. {flexablelib-2.0.7 → flexablelib-2.0.9/flexablelib.egg-info}/PKG-INFO +2 -2
  7. {flexablelib-2.0.7 → flexablelib-2.0.9}/package.json +1 -1
  8. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_merges.py +50 -0
  9. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_styles.py +28 -3
  10. {flexablelib-2.0.7 → flexablelib-2.0.9}/LICENSE +0 -0
  11. {flexablelib-2.0.7 → flexablelib-2.0.9}/MANIFEST.in +0 -0
  12. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/__init__.py +0 -0
  13. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/_speedups.c +0 -0
  14. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/_width_tables.h +0 -0
  15. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/cells.py +0 -0
  16. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/colors.py +0 -0
  17. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/columns.py +0 -0
  18. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/fast.py +0 -0
  19. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/options.py +0 -0
  20. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/readers.py +0 -0
  21. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/table.py +0 -0
  22. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/table_strings.py +0 -0
  23. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/text_width.py +0 -0
  24. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/utils.py +0 -0
  25. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib/writers.py +0 -0
  26. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib.egg-info/SOURCES.txt +0 -0
  27. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib.egg-info/dependency_links.txt +0 -0
  28. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib.egg-info/requires.txt +0 -0
  29. {flexablelib-2.0.7 → flexablelib-2.0.9}/flexablelib.egg-info/top_level.txt +0 -0
  30. {flexablelib-2.0.7 → flexablelib-2.0.9}/setup.cfg +0 -0
  31. {flexablelib-2.0.7 → flexablelib-2.0.9}/setup.py +0 -0
  32. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_cells.py +0 -0
  33. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_columns.py +0 -0
  34. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_excel.py +0 -0
  35. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_features.py +0 -0
  36. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_issues.py +0 -0
  37. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_merge_edge_matrix.py +0 -0
  38. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_readme_examples.py +0 -0
  39. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_text_width.py +0 -0
  40. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_two_pass_measurement.py +0 -0
  41. {flexablelib-2.0.7 → flexablelib-2.0.9}/tests/test_upstream_issues.py +0 -0
  42. {flexablelib-2.0.7 → flexablelib-2.0.9}/tools/benchmark.py +0 -0
  43. {flexablelib-2.0.7 → flexablelib-2.0.9}/tools/generate_width_tables.py +0 -0
@@ -2,6 +2,22 @@
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.9] - 2026-10-28
6
+
7
+ ### Added
8
+ - New ``blocks`` style: background-colour cells only — no outer/inner borders
9
+ and no junctions. Column gaps are a single space spacer; cell margin kept so
10
+ ANSI / Excel fills read as solid blocks.
11
+
12
+ ## [2.0.8] - 2026-10-28
13
+
14
+ ### Fixed
15
+ - Synthetic caps for multi-column merges clamp their horizontal run to the
16
+ merge's column span (no H bleeding into neighbour columns). Covers
17
+ column-only styles such as `grid_eheader` / `round_edges` / `pretty_columns`.
18
+ - Junction repair skips invisible/spacer vertical glyphs, so styles like
19
+ `simple` no longer pick up stray `┴`/`┼` on header and end rules.
20
+
5
21
  ## [2.0.7] - 2026-10-28
6
22
 
7
23
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib
3
- Version: 2.0.7
3
+ Version: 2.0.9
4
4
  Summary: Flexible console and HTML tables for Python
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Download-URL:
@@ -355,7 +355,7 @@ flexablelib/ # GitHub repository
355
355
  ├── docs/ issue history and design notes
356
356
  ├── logos/ brand assets — see logos/README.md
357
357
  ├── ARCHITECTURE.md how it all fits together
358
- ├── style_examples.md all 42 styles rendered
358
+ ├── style_examples.md all 43 styles rendered
359
359
  ├── package.json canonical version number; drives the release
360
360
  └── setup.py reads the version from package.json
361
361
  ```
@@ -306,7 +306,7 @@ flexablelib/ # GitHub repository
306
306
  ├── docs/ issue history and design notes
307
307
  ├── logos/ brand assets — see logos/README.md
308
308
  ├── ARCHITECTURE.md how it all fits together
309
- ├── style_examples.md all 42 styles rendered
309
+ ├── style_examples.md all 43 styles rendered
310
310
  ├── package.json canonical version number; drives the release
311
311
  └── setup.py reads the version from package.json
312
312
  ```
@@ -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,
@@ -130,6 +130,9 @@ Compositions = namedtuple(
130
130
 
131
131
  # Other
132
132
  'dashes',
133
+
134
+ # Fill-only (background colours, no border glyphs)
135
+ 'blocks',
133
136
  ]
134
137
  )
135
138
 
@@ -868,5 +871,24 @@ __style_compositions = Compositions(
868
871
  lines_with_indicator=[],
869
872
  align_indicator_margin=0,
870
873
  always_center_indicator=False
874
+ ),
875
+ # Background-colour blocks only: no outer/inner border glyphs, no junctions.
876
+ # Columns are separated by a single space (invisible spacer), not a rule.
877
+ blocks=TableComposition(
878
+ superior_header_line=None,
879
+ inferior_header_line=None,
880
+ superior_header_line_no_header=None,
881
+ table_body_line=None,
882
+ table_end_line=None,
883
+ vertical_header_lines=SeparatorLine(None, INVISIBLE_SEPARATOR, None, None),
884
+ vertical_table_body_lines=SeparatorLine(None, INVISIBLE_SEPARATOR, None, None),
885
+ margin=CELL_MARGIN,
886
+ align_sensitive=False,
887
+ align_indicator=None,
888
+ centered_indicator_on_sides=False,
889
+ left_and_right_when_centered=False,
890
+ lines_with_indicator=[],
891
+ align_indicator_margin=0,
892
+ always_center_indicator=False
871
893
  )
872
894
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib
3
- Version: 2.0.7
3
+ Version: 2.0.9
4
4
  Summary: Flexible console and HTML tables for Python
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Download-URL:
@@ -355,7 +355,7 @@ flexablelib/ # GitHub repository
355
355
  ├── docs/ issue history and design notes
356
356
  ├── logos/ brand assets — see logos/README.md
357
357
  ├── ARCHITECTURE.md how it all fits together
358
- ├── style_examples.md all 42 styles rendered
358
+ ├── style_examples.md all 43 styles rendered
359
359
  ├── package.json canonical version number; drives the release
360
360
  └── setup.py reads the version from package.json
361
361
  ```
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flexablelib",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "Flexible console and HTML tables for Python: styles, merges, colors, widths, decimal alignment.",
5
5
  "main": "__init__.py",
6
6
  "scripts": {
@@ -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
@@ -1,7 +1,7 @@
1
1
  """
2
2
  The style catalogue (``style_compositions.py``).
3
3
 
4
- Styles are data, not code: 42 ``TableComposition`` namedtuples. Nothing in the
4
+ Styles are data, not code: 43 ``TableComposition`` namedtuples. Nothing in the
5
5
  package validates them, so a malformed entry only shows up when a table is
6
6
  rendered with it. The smoke test below renders the same table in every style
7
7
  and checks the data survived.
@@ -33,10 +33,10 @@ def build_table(style_name):
33
33
  # The catalogue itself
34
34
  # +-------------------------------------------------------------------------+
35
35
 
36
- def test_the_catalogue_holds_42_styles():
36
+ def test_the_catalogue_holds_43_styles():
37
37
  # A canary: adding a style is meant to be purely additive, and the README,
38
38
  # ARCHITECTURE.md and style_examples.md all quote this number.
39
- assert len(ALL_STYLES) == 42
39
+ assert len(ALL_STYLES) == 43
40
40
 
41
41
 
42
42
  def test_style_names_are_unique():
@@ -187,3 +187,28 @@ def test_the_style_name_setter_works_from_any_directory(monkeypatch, tmp_path):
187
187
  def test_style_examples_is_present_at_the_repository_root():
188
188
  # Guards the fixture that makes the setter above usable in the suite.
189
189
  assert os.path.isfile(os.path.join(REPO_ROOT, 'style_examples.md'))
190
+
191
+
192
+ def test_blocks_style_is_in_the_catalogue():
193
+ assert 'blocks' in ALL_STYLES
194
+
195
+
196
+ def test_blocks_style_has_no_border_glyphs():
197
+ """blocks is fill-only: no box-drawing / ascii rule characters."""
198
+ table = build_table('blocks')
199
+ rendered = str(table)
200
+ for glyph in '┌┐└┘├┤┬┴┼│─═╪╧╤╞╡╒╘╛║╔╗╚╝┊┄╍+|':
201
+ assert glyph not in rendered, (glyph, rendered)
202
+
203
+
204
+ def test_blocks_style_keeps_cell_padding_for_background_fills():
205
+ import os
206
+ os.environ['FORCE_COLOR'] = '1'
207
+ os.environ.pop('NO_COLOR', None)
208
+ table = build_table('blocks')
209
+ table.use_colors = True
210
+ table.header_color = 'bold white on blue'
211
+ table.column_colors = {'Name': 'black on green'}
212
+ rendered = str(table)
213
+ assert '\x1b[' in rendered or '\033[' in rendered or '[' in rendered
214
+ assert '42m' in rendered or '44m' in rendered # green or blue bg
File without changes
File without changes
File without changes
File without changes