Skip to content

Commit c087d8d

Browse files
committed
More themes
1 parent 5d0a24c commit c087d8d

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

table2ascii/styles.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
from .table_style import TableStyle
22

33
thin = TableStyle.from_string("┌─┬─┐││ ├─┼─┤├─┼─┤└┴─┘")
4+
thin_box = TableStyle.from_string("┌─┬┬┐│││├─┼┼┤├─┼┼┤└┴┴┘")
45
thin_rounded = TableStyle.from_string("╭─┬─╮││ ├─┼─┤├─┼─┤╰┴─╯")
56
thin_compact = TableStyle.from_string("┌─┬─┐││ ├─┼─┤ └┴─┘")
67
thin_compact_rounded = TableStyle.from_string("╭─┬─╮││ ├─┼─┤ ╰┴─╯")
78
thin_thick = TableStyle.from_string("┌─┬─┐││ ┝━┿━┥├─┼─┤└┴─┘")
89
thin_thick_rounded = TableStyle.from_string("╭─┬─╮││ ┝━┿━┥├─┼─┤╰┴─╯")
910
thin_double = TableStyle.from_string("┌─┬─┐││ ╞═╪═╡├─┼─┤└┴─┘")
1011
thin_double_rounded = TableStyle.from_string("╭─┬─╮││ ╞═╪═╡├─┼─┤╰┴─╯")
12+
thick = TableStyle.from_string("┏━┳━┓┃┃ ┣━╋━┫┣━╋━┫┗┻━┛")
13+
thick_box = TableStyle.from_string("┏━┳┳┓┃┃┃┣━╋╋┫┣━╋╋┫┗┻┻┛")
1114
thick_compact = TableStyle.from_string("┏━┳━┓┃┃ ┣━╋━┫ ┗┻━┛")
1215
double = TableStyle.from_string("╔═╦═╗║║ ╠═╬═╣╠═╬═╣╚╩═╝")
16+
double_box = TableStyle.from_string("╔═╦╦╗║║║╠═╬╬╣╠═╬╬╣╚╩╩╝")
1317
double_compact = TableStyle.from_string("╔═╦═╗║║ ╠═╬═╣ ╚╩═╝")
1418
double_thin = TableStyle.from_string("╔═╦═╗║║ ╟─╫─╢╠═╬═╣╚╩═╝")
15-
minimalist = TableStyle.from_string(" ─── ━━━ ─── ── ")
19+
double_thin_compact = TableStyle.from_string("╔═╦═╗║║ ╟─╫─╢╠═╬═╣╚╩═╝")
20+
minimalist = TableStyle.from_string(" ─── │ ━━━ ─── ── ")
21+
borderless = TableStyle.from_string(" ┃ ━ ")
22+
ascii = TableStyle.from_string("+-+-+|| +-+-++-+-+++-+")
23+
ascii_box = TableStyle.from_string("+-+++|||+-++++-+++++++")
1624
ascii_compact = TableStyle.from_string("+-+-+|| +-+-+ ++-+")
1725
ascii_double = TableStyle.from_string("+-+-+|| +=+=++-+-+++-+")
18-
ascii_minimalist = TableStyle.from_string(" --- === --- -- ")
26+
ascii_minimalist = TableStyle.from_string(" --- | === --- -- ")
27+
ascii_borderless = TableStyle.from_string(" | - ")
28+
ascii_simple = TableStyle.from_string(" = | = ")
1929
markdown = TableStyle.from_string(" ||||-||| ")
2030

2131
# prints all themes with previews
@@ -24,21 +34,31 @@
2434

2535
styles = {
2636
"thin": thin,
37+
"thin_box": thin_box,
2738
"thin_rounded": thin_rounded,
2839
"thin_compact": thin_compact,
2940
"thin_compact_rounded": thin_compact_rounded,
3041
"thin_thick": thin_thick,
3142
"thin_thick_rounded": thin_thick_rounded,
3243
"thin_double": thin_double,
3344
"thin_double_rounded": thin_double_rounded,
45+
"thick": thick,
46+
"thick_box": thick_box,
3447
"thick_compact": thick_compact,
3548
"double": double,
49+
"double_box": double_box,
3650
"double_compact": double_compact,
3751
"double_thin": double_thin,
52+
"double_thin_compact": double_thin_compact,
3853
"minimalist": minimalist,
54+
"borderless": borderless,
55+
"ascii": ascii,
56+
"ascii_box": ascii_box,
3957
"ascii_compact": ascii_compact,
4058
"ascii_double": ascii_double,
4159
"ascii_minimalist": ascii_minimalist,
60+
"ascii_borderless": ascii_borderless,
61+
"ascii_simple": ascii_simple,
4262
"markdown": markdown,
4363
}
4464
for style in list(styles.keys()):
@@ -56,4 +76,4 @@
5676
last_col_heading=False,
5777
style=styles[style],
5878
)
59-
print(f"### `{style}`\n\n```\n{full}\n{body_only}```\n")
79+
print(f"### `{style}`\n\n```\n{full}\n\n{body_only}\n```\n")

table2ascii/table_to_ascii.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ def __row_to_ascii(
132132
# replace last seperator with symbol for edge of the row
133133
sep = right_edge
134134
output += sep
135+
# don't use separation row if it's only space
136+
if output.strip() == "":
137+
return ""
138+
# otherwise, return the row followed by newline
135139
return output + "\n"
136140

137141
def __top_edge_to_ascii(self) -> str:
@@ -182,9 +186,6 @@ def __body_to_ascii(self) -> str:
182186
right_edge=self.__style.row_right_tee,
183187
filler=self.__style.row_sep,
184188
)
185-
# don't use separation row if it's only space
186-
if separation_row.strip() == "":
187-
separation_row = ""
188189
return separation_row.join(
189190
self.__row_to_ascii(
190191
left_edge=self.__style.left_and_right_edge,
@@ -213,7 +214,7 @@ def to_ascii(self) -> str:
213214
# bottom row of table
214215
table += self.__bottom_edge_to_ascii()
215216
# reurn ascii table
216-
return table
217+
return table.strip("\n")
217218

218219

219220
def table2ascii(**options) -> str:

0 commit comments

Comments
 (0)