GithubHelp home page GithubHelp logo

Comments (8)

edisonhello avatar edisonhello commented on June 1, 2024 1

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.

p-ranav avatar p-ranav commented on June 1, 2024

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 of std::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.

maximiliank avatar maximiliank commented on June 1, 2024

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.

tqolf avatar tqolf commented on June 1, 2024

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.

tqolf avatar tqolf commented on June 1, 2024

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.

截屏2021-10-20 11 58 22

from tabulate.

p-ranav avatar p-ranav commented on June 1, 2024

A pull request would be greatly appreciated :)

from tabulate.

791136190 avatar 791136190 commented on June 1, 2024

Is there a support plan for this feature?

from tabulate.

sandmeteor avatar sandmeteor commented on June 1, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.