10BC0 UnicodeLight and UnicodeBold table styles. · markkurossi/tabulate@063aae1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 063aae1

Browse files
committed
UnicodeLight and UnicodeBold table styles.
1 parent e625a1a commit 063aae1

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,32 @@ drawing characters to render the table borders:
195195
│ 2020 │ 107 │ 50 │
196196
└──────┴────────┴──────────┘
197197

198+
## UnicodeLight
199+
200+
The UnicodeLight format creates a new tabulator that uses thin Unicode
201+
line drawing characters to render the table borders:
202+
203+
┌──────┬────────┬──────────┐
204+
│ Year │ Income │ Expenses │
205+
├──────┼────────┼──────────┤
206+
│ 2018 │ 100 │ 90 │
207+
│ 2019 │ 110 │ 85 │
208+
│ 2020 │ 107 │ 50 │
209+
└──────┴────────┴──────────┘
210+
211+
## UnicodeBold
212+
213+
The UnicodeBold format creates a new tabulator that uses thick Unicode
214+
line drawing characters to render the table borders:
215+
216+
┏━━━━━━┳━━━━━━━━┳━━━━━━━━━━┓
217+
┃ Year ┃ Income ┃ Expenses ┃
218+
┣━━━━━━╋━━━━━━━━╋━━━━━━━━━━┫
219+
┃ 2018 ┃ 100 ┃ 90 ┃
220+
┃ 2019 ┃ 110 ┃ 85 ┃
221+
┃ 2020 ┃ 107 ┃ 50 ┃
222+
┗━━━━━━┻━━━━━━━━┻━━━━━━━━━━┛
223+
198224
## Colon
199225

200226
The Colon format creates a new tabulator that uses colon (':')

tabulate.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const (
4141
Plain Style = iota
4242
ASCII
4343
Unicode
44+
UnicodeLight
45+
UnicodeBold
4446
Colon
4547
Simple
4648
Github
@@ -92,6 +94,42 @@ var asciiBorder = Border{
9294
BR: "+",
9395
}
9496

97+
var unicodeLight = Border{
98+
HT: "\u2500",
99+
HM: "\u2500",
100+
HB: "\u2500",
101+
VL: "\u2502",
102+
VM: "\u2502",
103+
VR: "\u2502",
104+
TL: "\u250C",
105+
TM: "\u252c",
106+
TR: "\u2510",
107+
ML: "\u251C",
108+
MM: "\u253C",
109+
MR: "\u2524",
110+
BL: "\u2514",
111+
BM: "\u2534",
112+
BR: "\u2518",
113+
}
114+
115+
var unicodeBold = Border{
116+
HT: "\u2501",
117+
HM: "\u2501",
118+
HB: "\u2501",
119+
VL: "\u2503",
120+
VM: "\u2503",
121+
VR: "\u2503",
122+
TL: "\u250F",
123+
TM: "\u2533",
124+
TR: "\u2513",
125+
ML: "\u2523",
126+
MM: "\u254B",
127+
MR: "\u252B",
128+
BL: "\u2517",
129+
BM: "\u253B",
130+
BR: "\u251B",
131+
}
132+
95133
var borders = map[Style]Borders{
96134
Plain: {},
97135
ASCII: {
@@ -134,6 +172,14 @@ var borders = map[Style]Borders{
134172
BR: "\u2518",
135173
},
136174
},
175+
UnicodeLight: {
176+
Header: unicodeLight,
177+
Body: unicodeLight,
178+
},
179+
UnicodeBold: {
180+
Header: unicodeBold,
181+
Body: unicodeBold,
182+
},
137183
Colon: {
138184
Header: Border{
139185
VM: " : ",

tabulate_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func align(align Align) {
4040
tabulate(New(Plain), align).Print(os.Stdout)
4141
tabulate(New(ASCII), align).Print(os.Stdout)
4242
tabulate(New(Unicode), align).Print(os.Stdout)
43+
tabulate(New(UnicodeLight), align).Print(os.Stdout)
44+
tabulate(New(UnicodeBold), align).Print(os.Stdout)
4345
tabulate(New(Colon), align).Print(os.Stdout)
4446
tabulate(New(Simple), align).Print(os.Stdout)
4547
tabulate(New(Github), align).Print(os.Stdout)

0 commit comments

Comments
 (0)
0