Skip to content

Commit ff9dc4c

Browse files
authored
Update README.md
1 parent 260a6ed commit ff9dc4c

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

README.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -124,69 +124,6 @@ You could also use `Table.print(stream)` to print the table, e.g., `universal_co
124124
<img src="img/universal_constants.png"/>
125125
</p>
126126

127-
### AsciiDoc
128-
129-
Tabulate can export tables as AsciiDoc using an `AsciiDocExporter`.
130-
131-
```cpp
132-
#include <tabulate/asciidoc_exporter.hpp>
133-
using namespace tabulate;
134-
135-
int main() {
136-
Table movies;
137-
movies.add_row({"S/N", "Movie Name", "Director", "Estimated Budget", "Release Date"});
138-
movies.add_row({"tt1979376", "Toy Story 4", "Josh Cooley", "$200,000,000", "21 June 2019"});
139-
movies.add_row({"tt3263904", "Sully", "Clint Eastwood", "$60,000,000", "9 September 2016"});
140-
movies.add_row(
141-
{"tt1535109", "Captain Phillips", "Paul Greengrass", "$55,000,000", " 11 October 2013"});
142-
143-
// center align 'Director' column
144-
movies.column(2).format().font_align(FontAlign::center);
145-
146-
// right align 'Estimated Budget' column
147-
movies.column(3).format().font_align(FontAlign::right);
148-
149-
// right align 'Release Date' column
150-
movies.column(4).format().font_align(FontAlign::right);
151-
152-
movies[1][2].format().font_style({FontStyle::bold, FontStyle::italic});
153-
movies[2][1].format().font_style({FontStyle::italic});
154-
155-
// Color header cells
156-
for (size_t i = 0; i < 5; ++i) {
157-
movies[0][i]
158-
.format()
159-
.font_color(Color::white)
160-
.font_style({FontStyle::bold})
161-
.background_color(Color::blue);
162-
}
163-
164-
AsciiDocExporter exporter;
165-
auto asciidoc = exporter.dump(movies);
166-
167-
// tabulate::table
168-
std::cout << movies << "\n\n";
169-
170-
// Exported AsciiDoc
171-
std::cout << asciidoc << std::endl;
172-
}
173-
```
174-
Below is the export of the example above:
175-
176-
```
177-
[cols="<,<,^,>,>"]
178-
|===
179-
|*S/N*|*Movie Name*|*Director*|*Estimated Budget*|*Release Date*
180-
181-
|tt1979376|Toy Story 4|*_Josh Cooley_*|$200,000,000|21 June 2019
182-
|tt3263904|_Sully_|Clint Eastwood|$60,000,000|9 September 2016
183-
|tt1535109|Captain Phillips|Paul Greengrass|$55,000,000| 11 October 2013
184-
|===
185-
```
186-
The rendered output you can see here: http://tpcg.io/pbbfU3ks
187-
188-
**NOTE** Alignment is only supported per column. The font styles `FontStyle::bold` and `FontStyle::italic` can be used for each cell, also in combination.
189-
190127
## Formatting Options
191128

192129
### Style Inheritance Model
@@ -716,6 +653,69 @@ The above table renders in Markdown like below.
716653
| tt3263904 | Sully | Clint Eastwood | $60,000,000 | 9 September 2016 |
717654
| tt1535109 | Captain Phillips | Paul Greengrass | $55,000,000 | 11 October 2013 |
718655

656+
### AsciiDoc
657+
658+
Tabulate can export tables as AsciiDoc using an `AsciiDocExporter`.
659+
660+
```cpp
661+
#include <tabulate/asciidoc_exporter.hpp>
662+
using namespace tabulate;
663+
664+
int main() {
665+
Table movies;
666+
movies.add_row({"S/N", "Movie Name", "Director", "Estimated Budget", "Release Date"});
667+
movies.add_row({"tt1979376", "Toy Story 4", "Josh Cooley", "$200,000,000", "21 June 2019"});
668+
movies.add_row({"tt3263904", "Sully", "Clint Eastwood", "$60,000,000", "9 September 2016"});
669+
movies.add_row(
670+
{"tt1535109", "Captain Phillips", "Paul Greengrass", "$55,000,000", " 11 October 2013"});
671+
672+
// center align 'Director' column
673+
movies.column(2).format().font_align(FontAlign::center);
674+
675+
// right align 'Estimated Budget' column
676+
movies.column(3).format().font_align(FontAlign::right);
677+
678+
// right align 'Release Date' column
679+
movies.column(4).format().font_align(FontAlign::right);
680+
681+
movies[1][2].format().font_style({FontStyle::bold, FontStyle::italic});
682+
movies[2][1].format().font_style({FontStyle::italic});
683+
684+
// Color header cells
685+
for (size_t i = 0; i < 5; ++i) {
686+
movies[0][i]
687+
.format()
688+
.font_color(Color::white)
689+
.font_style({FontStyle::bold})
690+
.background_color(Color::blue);
691+
}
692+
693+
AsciiDocExporter exporter;
694+
auto asciidoc = exporter.dump(movies);
695+
696+
// tabulate::table
697+
std::cout << movies << "\n\n";
698+
699+
// Exported AsciiDoc
700+
std::cout << asciidoc << std::endl;
701+
}
702+
```
703+
Below is the export of the example above:
704+
705+
```
706+
[cols="<,<,^,>,>"]
707+
|===
708+
|*S/N*|*Movie Name*|*Director*|*Estimated Budget*|*Release Date*
709+
710+
|tt1979376|Toy Story 4|*_Josh Cooley_*|$200,000,000|21 June 2019
711+
|tt3263904|_Sully_|Clint Eastwood|$60,000,000|9 September 2016
712+
|tt1535109|Captain Phillips|Paul Greengrass|$55,000,000| 11 October 2013
713+
|===
714+
```
715+
The rendered output you can see here: http://tpcg.io/pbbfU3ks
716+
717+
**NOTE** Alignment is only supported per column. The font styles `FontStyle::bold` and `FontStyle::italic` can be used for each cell, also in combination.
718+
719719
## Building Samples
720720

721721
There are a number of samples in the `samples/` directory, e.g., [Mario](https://github.com/p-ranav/tabulate/blob/master/samples/mario.cpp). You can build these samples by running the following commands.

0 commit comments

Comments
 (0)