MarkdownTableWriter outputs ANSI Escape Sequences
See original GitHub issueProblem
Creating a MarkdownTableWriter and specifying a column style with font_weight="bold"
results in the correct **content**
being output, but also the entire column data (including the asterisks) are surrounded by ANSI escape sequences for bold text. The report I’m generating is eventually sent through pandoc
which renders the ANSI sequences as ugly \xAB
characters in a browser.
Expected output
A normal table cell just with **
wrapped on either side of the data. No ANSI escape sequences.
Steps to reproduce
Python 3.8.3 (default, May 17 2020, 18:15:42)
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytablewriter
>>> writer = pytablewriter.MarkdownTableWriter()
>>> writer.headers = ["Test", "Test"]
>>> writer.value_matrix = [("hello", "world"), ("goodbye", "world")]
>>> writer.column_styles = [pytablewriter.style.Style(font_weight="bold"), pytablewriter.style.Style()]
>>> import sys
>>> writer.dump(sys.stdout, close_after_write=False)
| Test |Test |
|-----------|-----|
|**hello** |world|
|**goodbye**|world|
You can’t see the ANSI escape sequences above, obviously, but they are there when I just tested it. I also just installed the most recent version from PyPI, and my Python version is seen above in the output.
edit: forgot to mention, this also happens when writing somewhere that is not stdout
. My use-case is actually writing to a file through writer.dump
. The example above was just a PoC.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
For
MarkdownTableWriter
class, some styles are not available. Other than that, not so changed significantly.You can find change logs at https://github.com/thombashi/pytablewriter/releases
I had released
pytablewriter 0.55.0
. In this version,dump
method will disable ANSI escape sequences during the execution.You can also disable ANSI escape by manual via
enable_ansi_escape
attribute of writer classes for other methods likewrite_table
/dumps