Comments (8)
An easy bypass of this issue is to convert the table to string manually with termcolor::colorize, enable the multibyte char, and then limit the width manually.
from tabulate.
Yeah this is a known issue and it has to do with std::stringstream
not retaining the termcolor
colors.
Essentially, how nested tables are implemented are as follows:
- The inner table is converted to string (using
std::stringstream
as the stream, instead ofstd::cout
)- Relevant source here.
- The outer table cell value is now the inner table string, serialized in the previous step
- The outer table is then fully printed to
std::cout
If the inner table colors were preserved in the first step, this would work as we want. Unfortunately, this is not the case.
Nested table support was added as sort of an after-thought/bonus feature. I may have to just implement printing of nested tables with iteration (starting from the outer table and going in), which is non-ideal.
from tabulate.
Thank you for your reply.
I tried to add << termcolor::colorize
, see ikalnytskyi/termcolor#20, to the inline void Printer::print_table(std::ostream &stream, TableInternal &table)
function. The color works, but the right borders are messed up.
Do you think it could work this way?
from tabulate.
ansi escape sequence should be considered in get_sequence_length to support colorful nested table. I have implemented by myself https://github.com/vxfury/tabulate. and with true color supported, too.
from tabulate.
ansi escape sequence should be considered in get_sequence_length to support colorful nested table. I have implemented by myself https://github.com/vxfury/tabulate. and with true color supported, too.
from tabulate.
A pull request would be greatly appreciated :)
from tabulate.
Is there a support plan for this feature?
from tabulate.
@edisonhello can you give code for this 'bypass' ?
@vxfury link https://github.com/vxfury/tabulate is not available - is it a chance to get this piece of code?
from tabulate.
Related Issues (20)
- Release 1.5 is backward incompatible HOT 1
- How to print std::vector<std::string> into a row? HOT 3
- How do I acheive this table formatting? HOT 1
- How do I initialize an n*m Table? HOT 1
- why it cannot run correctly in windows os? HOT 14
- Correct table filled area shape method
- you are pulling 'std::variant' into the global namespace (bad idea) HOT 2
- Support Unicode box drawing
- std::locale::global is unsafe
- After using print_table function, stream style is not correct HOT 1
- Printing to stringstream and retaining formatting HOT 1
- Print strings with newlines and indentation HOT 3
- Option to not strip leading (or trailing) whitespace in line-wrapped text? HOT 1
- Add option to remove entire columns
- Tableau c++ graphique
- Combining live-refresh tabulate + indicators
- How to write black text when Color::black does not exist
- Nested tables, how to support different colors for different grids HOT 1
- How can i indent the table ? HOT 1
- Hitting some compilation errors (shadow variable, implicit cast) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tabulate.