Open Anteru opened 5 years ago
This issue is also present for the png
formatter.
Using the png
formatter:
pygmentize -f png -O style=murphy -o foo.png foo.py
Using the html
formatter:
pygmentize -f html -O style=murphy,full -o foo.html foo.py
Looking a bit into this, this is by design. The background color used for tokens is the background color for the token, and solarized-dark
does not specify any background color on a token (except for Error
), and indeed, for error, a background color will get generated. Now, we can change the RTF output to have the background color set for everything, but that's a breaking change. @birkenfeld Any thoughts?
(apologies for this being off-topic for the RTF formatter) Looking into the image formatter, I realized it had no functionality to support background colors. PR https://github.com/pygments/pygments/pull/1374 aims to fix that issue.
Is this resolved now, can background color be added to word docs or rtfs?
@shamitb It is already part of the RTF-formatter using the \cbN
control word: {\cb25 '}{\cb25 foo}{\cb25 '}
, but according to the RTF 1.9 specification Windows versions of Word have never supported the \cbN
control word (and from my tests neither does WordPad Win10, LibreOffice or OpenOffice):
Note: Windows versions of Word have never supported \cbN, but it can be emulated by the control word sequence \chshdng0\chcbpatN.
All of WordPad, LibreOffice and OpenOffice does appear to support \chshdng0\chcbpatN
, so we could use those control words instead (or \highlightN
).
.rtf renamed to .txt for uploading issue1208.py.txt
You can test an implementation here:
git clone https://github.com/jonascj/pygments
cd pygments
git checkout issue1208-bgcolor
python -m venv venv
# activate venv (`source venv/bin/activate` or `venv\Scripts\activate.bat`)
pip install -e .
python -m pygments -O style=murphy -v -o issue1208.py.rtf issue1208.py
The question is which combination of control words would render as expected in the most RTF-viewers - \chshdng0\chcbpatN
, \highlightN
or \cbN
(the last one appears to be ignored by all major readers I've tested). The first two works in the same readers.
(Original issue 1504 created by dansimau on 2019-04-09T08:32:41.068432+00:00)
When running pygmentize with RTF output and a theme with a background color, I expect the RTF output to have the background color matching the theme.
However, the RTF output does not have any background color set, e.g.:
What I am expecting is the RTF output to have the background color set using the
\cbN
control word.