Skip to content

Commit b3f6a2e

Browse files
committed
Add headings and custom style info
1 parent f8bfd87 commit b3f6a2e

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Module for converting 2D Python lists to a fancy ASCII/Unicode tables
1010
- [table2ascii](#table2ascii)
1111
- [📥 Installation](#-installation)
1212
- [🧑‍💻 Usage](#-usage)
13+
- [Convert lists to ASCII tables](#convert-lists-to-ascii-tables)
14+
- [Set first or last column headings](#set-first-or-last-column-headings)
15+
- [Set column widths and alignments](#set-column-widths-and-alignments)
16+
- [Use a preset style](#use-a-preset-style)
17+
- [Define a custom style](#define-a-custom-style)
1318
- [🎨 Preset styles](#-preset-styles)
1419
- [⚙️ Options](#️-options)
1520
- [👨‍🎨 Use cases](#-use-cases)
@@ -25,7 +30,7 @@ Module for converting 2D Python lists to a fancy ASCII/Unicode tables
2530

2631
## 🧑‍💻 Usage
2732

28-
Convert Python lists to ASCII tables
33+
### Convert lists to ASCII tables
2934

3035
```py
3136
from table2ascii import table2ascii
@@ -50,6 +55,8 @@ print(output)
5055
"""
5156
```
5257

58+
### Set first or last column headings
59+
5360
```py
5461
from table2ascii import table2ascii
5562

@@ -68,6 +75,8 @@ print(output)
6875
"""
6976
```
7077

78+
### Set column widths and alignments
79+
7180
```py
7281
from table2ascii import table2ascii, Alignment
7382

@@ -91,6 +100,8 @@ print(output)
91100
"""
92101
```
93102

103+
### Use a preset style
104+
94105
```py
95106
from table2ascii import table2ascii, PresetStyle
96107

@@ -114,6 +125,34 @@ print(output)
114125
"""
115126
```
116127

128+
### Define a custom style
129+
130+
Check [`TableStyle`](https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/table_style.py) for more info and [`PresetStyle`](https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/preset_style.py) for examples.
131+
132+
```py
133+
from table2ascii import table2ascii, TableStyle
134+
135+
my_style = TableStyle.from_string("*-..*||:+-+:+ *''*")
136+
137+
output = table2ascii(
138+
header=["First", "Second", "Third"],
139+
body=[["10", "30", "40"], ["20", "10", "20"], ["30", "20", "30"]],
140+
style=my_style
141+
)
142+
143+
print(output)
144+
145+
"""
146+
*-------.--------.-------*
147+
| First : Second : Third |
148+
+-------:--------:-------+
149+
| 10 : 30 : 40 |
150+
| 20 : 10 : 20 |
151+
| 30 : 20 : 30 |
152+
*-------'--------'-------*
153+
"""
154+
```
155+
117156
## 🎨 Preset styles
118157

119158
See a list of all preset styles [here](/style_list).

0 commit comments

Comments
 (0)