beautifultable
beautifultable copied to clipboard
[Question/discussion] Handling other "codes to escape" in tables
Hi,
I was pleased to find that BeautifulTable
does support ANSI colors. I haven't explored the code yet so I have no idea how that works, but I would like to know if there's a "relatively easy" way to support other, non-ANSI codes.
The basic idea is, like ANSI colors, to have an API to add "tags" to be ignored, that is, tags that don't "count" in a cell's length and would be closed before the cell, should the cell be split on several lines. HTML-like codes might be nice, for instance:
A cell <r>partly in red.</r>
Of course, it would be possible to replace <r>
with the ANSI code for red, and </r>
with the ANSI code for the end of the color tag. But if there's a clear API to do this, I would prefer to using it.
I know this is kind of specialized, and the interest might seem pretty limited, so that's an open-ended question.
Thanks for this tool,
This does seem like a good thing to have but I'm not sure if providing a built in general solution is feasible due to difference in rules between various formats. Although an extendible class which handles the parsing would be a decent enough solution. As a workaround you could try to monkeypatch utils.textwrap
function and roll out your own implementation of wrapping html text.