span-table
span-table is a lightweight Python helper for rendering ASCII tables with merged cells using Rich-style markup.
Features
- Render table layouts with custom merged spans
- Support multi-line cell content
- Uses
richbox styles for flexible borders - Compatible with Python
>=3.14
Installation
pip install span-table
Quick Start
from span_table import span_table
from rich import print
table = [
["Header 1", "Header 2", "Header3", "Header 4"],
["row 1", "column 2", "column 3", "column 4"],
["row 2", "Cells span columns.", "", ""],
["row 3", "Cells\nspan rows.", "- Cells\n- contain\n- blocks", ""],
["row 4", "", "", ""]
]
# Spans are defined as ((start_row, start_col), (end_row, end_col)) with zero-based indexes
my_spans = [
((2, 1), (2, 3)),
((3, 1), (4, 1)),
((3, 2), (4, 3)),
]
print(span_table(table, my_spans))
This renders:
┌──────────┬────────────┬──────────┬──────────┐
│ Header 1 │ Header 2 │ Header3 │ Header 4 │
├──────────┼────────────┼──────────┼──────────┤
│ row 1 │ column 2 │ column 3 │ column 4 │
├──────────┼────────────┴──────────┴──────────┤
│ row 2 │ Cells span columns. │
├──────────┼────────────┬─────────────────────┤
│ row 3 │ Cells │ - Cells │
├──────────┤ span rows. │ - contain │
│ row 4 │ │ - blocks │
└──────────┴────────────┴─────────────────────┘
Advanced Usage
from span_table import span_table
from rich import print
table = [
["Time", "[on red]Height[/]", "", "[on green]Weight[/]", ""],
["", "Total", "Change", "Total", "Change"],
["15:30", "1", "2", "3", "4"]
]
spans = [
((0, 0), (1, 0)),
((0, 1), (0, 2)),
((0, 3), (0, 4))
]
print(span_table(table, spans, border_style="red"))
This renders:
┌───────┬────────────────┬────────────────┐
│ Time │<red bg> Height │<Green BG>Weight│
│ ├───────┬────────┼───────┬────────┤
│ │ Total │ Change │ Total │ Change │
├───────┼───────┼────────┼───────┼────────┤
│ 15:30 │ 1 │ 2 │ 3 │ 4 │
└───────┴───────┴────────┴───────┴────────┘
API
span_table(data, spans, box=rich_box.SQUARE, border_style=str | Style) -> str
Render a text table with optional merged cells.
data:list[list[str]]— table rows and columnsspans:list[tuple[tuple[int, int], tuple[int, int]]]— list of merge regionsbox:rich.box.Box— optional Rich box style such asbox.SQUAREborder_style:strorrich.style.Style- optional style for borders
Span rules
- Each span is a rectangular region defined by a start and end coordinate
- Coordinates are zero-based:
(row_index, column_index) - Spans can cover a single cell or multiple cells
- Spans must be within the table bounds
Rich markup support
Cell values may include Rich markup tags such as [bold], [italic], or color tags. The library preserves markup while measuring text layout.
Notes
- Ensure each row has the same number of columns
- Non-merged cells may be omitted from
spans - The library automatically fills any cells not included in spans as standard individual cells
Metadata
Release files for span-table 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| span_table-0.4.0.tar.gz | 27.5 kB | Without provenance | Details for span_table-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| span_table-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for span_table-0.4.0-py3-none-any.whl |
Total release size: 35.8 kB
Release files / span_table-0.4.0.tar.gz
| Download URL | span_table-0.4.0.tar.gz |
|---|---|
| Size | 27.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca68b5b322da43e5bfaece42811d0a3405b3cf5ed7942e610bc9e97d10c61ced
|
|
BLAKE2b-256 checksum How to use checksums |
519e36ae2dac9e9d581b0f46e4c7659d1c81de415e31f18abb92510bc9351bff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / span_table-0.4.0-py3-none-any.whl
| Download URL | span_table-0.4.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8d08775b9ca4360d1fabc452304909673e4b6ad504528f1c8de82d2c7003aba
|
|
BLAKE2b-256 checksum How to use checksums |
599549cc5b9d6b68e8d254134df80ad3bcfc6a84e2aadc9cc2019992bddfe017
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for span-table 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.