Skip to content

Commit 079f374

Browse files
Merge a5530ab into master
2 parents 619d962 + a5530ab commit 079f374

File tree

8 files changed

+100
-59
lines changed

8 files changed

+100
-59
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 0.5.0+1
1+
# 0.5.1
22

33
- Added `style` argument to switch between Markdown and MySQL
44
- Added `border` argument, allowing vertical and horizontal outer borders

README.md

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
![Generic badge](https://img.shields.io/badge/status-it_works-ok.svg)
2-
![Generic badge](https://img.shields.io/badge/testing_on-VM_|_JS-blue.svg)
3-
[![pub points](https://badges.bar/tabular/pub%20points)](https://pub.dev/packages/tabular/score)
4-
[![Actions Status](https://github.com/rtmigo/tabular/workflows/unittest/badge.svg?branch=master)](https://github.com/rtmigo/tabular/actions)
5-
61
# [Tabular](https://github.com/rtmigo/tabular_dart#tabular)
72

83
Dart library for easily displaying tabular data in a visually appealing
@@ -61,6 +56,52 @@ Winter | 12 | December | 31 | 258
6156

6257
# Formatting
6358

59+
## Modify alignment
60+
61+
``` dart
62+
tabular(data, align: {'Name': Side.center, 'Sun': Side.start})
63+
```
64+
65+
``` text
66+
Season | # | Name | Days | Sun
67+
-------|----|-----------|------|------
68+
Winter | 1 | January | 31 | 94
69+
Winter | 2 | February | 28 | 123
70+
Spring | 3 | March | 31 | 42
71+
Spring | 4 | April | 30 | 243
72+
Spring | 5 | May | 31 | 5523
73+
Summer | 6 | June | 30 | 11251
74+
Summer | 7 | July | 31 | 17451
75+
Summer | 8 | August | 31 | 18707
76+
Autumn | 9 | September | 30 | 7025
77+
Autumn | 10 | October | 31 | 5041
78+
Autumn | 11 | November | 30 | 2302
79+
Winter | 12 | December | 31 | 258
80+
```
81+
82+
## Add markdown ':' alignment marks
83+
84+
``` dart
85+
tabular(data, markdownAlign: true)
86+
```
87+
88+
``` text
89+
Season | # | Name | Days | Sun
90+
-------|---:|-----------|-----:|-----:
91+
Winter | 1 | January | 31 | 94
92+
Winter | 2 | February | 28 | 123
93+
Spring | 3 | March | 31 | 42
94+
Spring | 4 | April | 30 | 243
95+
Spring | 5 | May | 31 | 5523
96+
Summer | 6 | June | 30 | 11251
97+
Summer | 7 | July | 31 | 17451
98+
Summer | 8 | August | 31 | 18707
99+
Autumn | 9 | September | 30 | 7025
100+
Autumn | 10 | October | 31 | 5041
101+
Autumn | 11 | November | 30 | 2302
102+
Winter | 12 | December | 31 | 258
103+
```
104+
64105
## Add vertical border
65106

66107
``` dart
@@ -112,52 +153,6 @@ tabular(data, style: Style.mysql, border: Border.all)
112153
+--------+----+-----------+------+-------+
113154
```
114155

115-
## Add markdown ':' alignment marks
116-
117-
``` dart
118-
tabular(data, markdownAlign: true)
119-
```
120-
121-
``` text
122-
Season | # | Name | Days | Sun
123-
-------|---:|-----------|-----:|-----:
124-
Winter | 1 | January | 31 | 94
125-
Winter | 2 | February | 28 | 123
126-
Spring | 3 | March | 31 | 42
127-
Spring | 4 | April | 30 | 243
128-
Spring | 5 | May | 31 | 5523
129-
Summer | 6 | June | 30 | 11251
130-
Summer | 7 | July | 31 | 17451
131-
Summer | 8 | August | 31 | 18707
132-
Autumn | 9 | September | 30 | 7025
133-
Autumn | 10 | October | 31 | 5041
134-
Autumn | 11 | November | 30 | 2302
135-
Winter | 12 | December | 31 | 258
136-
```
137-
138-
## Modify alignment
139-
140-
``` dart
141-
tabular(data, align: {'Name': Side.center, 'Sun': Side.start})
142-
```
143-
144-
``` text
145-
Season | # | Name | Days | Sun
146-
-------|----|-----------|------|------
147-
Winter | 1 | January | 31 | 94
148-
Winter | 2 | February | 28 | 123
149-
Spring | 3 | March | 31 | 42
150-
Spring | 4 | April | 30 | 243
151-
Spring | 5 | May | 31 | 5523
152-
Summer | 6 | June | 30 | 11251
153-
Summer | 7 | July | 31 | 17451
154-
Summer | 8 | August | 31 | 18707
155-
Autumn | 9 | September | 30 | 7025
156-
Autumn | 10 | October | 31 | 5041
157-
Autumn | 11 | November | 30 | 2302
158-
Winter | 12 | December | 31 | 258
159-
```
160-
161156
## Custom column formatting
162157

163158
``` dart

example/example.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:tabular/src/inner.dart';
21
import 'package:tabular/tabular.dart';
32

43
void main() {

lib/src/inner.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ List<Side> createColToAlign<T>(CellsMatrix matrix, Map<dynamic, Side>? align) {
370370
return colToAlign;
371371
}
372372

373+
const split_line = ['4b9db54d-426d-4b83-bf00-2858b5947d50'];
374+
375+
bool isSplitLine(List<dynamic> row) => row==split_line;
376+
373377
/// Converts a set of cells defined by a two-dimensional list to a Markdown formatted ASCII table.
374378
/// Returns a string with the table that is ready for printing.
375379
///
@@ -393,8 +397,7 @@ List<Side> createColToAlign<T>(CellsMatrix matrix, Map<dynamic, Side>? align) {
393397
/// the header. These symbols tell services like GitHub which way to align the columns after
394398
/// converting the table to HTML.
395399
///
396-
/// [outerBorder] determines whether to add vertical borders to the left and right sides
397-
/// of the table.
400+
/// [border] determines whether to determines which outer border to add to the table.
398401
String tabular(List<List<dynamic>> rows,
399402
{Map<dynamic, Side>? align,
400403
Map<dynamic, FormatCell>? format,

lib/tabular.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-FileCopyrightText: (c) 2021 Artёm IG <github.com/rtmigo>
22
// SPDX-License-Identifier: MIT
33

4-
5-
export 'src/inner.dart' show tabular, Sort, Side, FormatCell, CompareCells;
4+
export 'src/inner.dart' show tabular, Sort, Side, FormatCell, CompareCells, split_line, Style, Border;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: tabular
22
description: Dart library for easily displaying tabular data in a visually appealing ASCII table format.
3-
version: 0.5.0+1
3+
version: 0.5.1
44
repository: https://github.com/rtmigo/tabular_dart
55

66

test/borders_test.dart

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
// SPDX-FileCopyrightText: (c) 2021 Artёm IG <github.com/rtmigo>
22
// SPDX-License-Identifier: MIT
33

4-
import 'package:tabular/src/inner.dart';
54
import 'package:tabular/tabular.dart';
65
import 'package:test/test.dart';
76

87
import 'common.dart';
98

109
void main() {
10+
11+
var splitline_date = [
12+
['Season', '#', 'Name', 'Days', 'Sun'],
13+
['Winter', 12, 'December', 31, 258],
14+
['Winter', 1, 'January', 31, 94],
15+
['Winter', 2, 'February', 28, 123],
16+
split_line,
17+
['Spring', 3, 'March', 31, 42],
18+
['Spring', 4, 'April', 30, 243],
19+
['Spring', 5, 'May', 31, 5523],
20+
split_line,
21+
['Summer', 6, 'June', 30, 11251],
22+
['Summer', 7, 'July', 31, 17451],
23+
['Summer', 8, 'August', 31, 18707],
24+
split_line,
25+
['Autumn', 9, 'September', 30, 7025],
26+
['Autumn', 10, 'October', 31, 5041],
27+
['Autumn', 11, 'November', 30, 2302],
28+
29+
];
30+
1131
group('markdown', () {
1232

1333
test('no border', () {
@@ -138,5 +158,18 @@ void main() {
138158
'''.trim().noSpaces());
139159
});
140160

161+
// test('all and split', () {
162+
// var t = tabular(months, style: Style.mysql, border: Border.vertical);
163+
// //print(t.spaceToDot());
164+
//
165+
// expect(t.spaceToDot(), '''
166+
// |.Winter...|.Spring.|.Summer.|.Autumn....|
167+
// +----------+--------+--------+-----------+
168+
// |.December.|.March..|.June...|.September.|
169+
// |.January..|.April..|.July...|.October...|
170+
// |.February.|.May....|.August.|.November..|
171+
// '''.trim().noSpaces());
172+
// });
173+
141174
});
142175
}

test/inner_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: (c) 2021 Artёm IG <github.com/rtmigo>
2+
// SPDX-License-Identifier: MIT
3+
4+
import 'package:tabular/src/inner.dart';
5+
import 'package:test/test.dart';
6+
7+
void main() {
8+
test('split line', () {
9+
expect(isSplitLine(split_line), true);
10+
expect(isSplitLine(['anything']), false);
11+
});
12+
}

0 commit comments

Comments
 (0)