How to print Syntax without trailing whitespace? #3243
Unanswered
thatlittleboy
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there, I'm using
rich==13.5.2
, python 3.10, and when trying to print syntax highlighted code in Jupyter, I'm getting trailing whitespaces which makes it inconvenient to copy, see image below:My desired outcome is for the trailing whitespaces to not exist.
I came across this issue while trying to fix this problem, #2647 , but the suggested solution there (
WhitespaceStrippingConsole
didn't work for me), here is my attempt anyway:(I had to modify it a little because each line ending wasn't
\n
, it was\x1b[0m
.But it doesn't work, there are still trailing whitespaces as seen from the image above. I'm sure that the monkey-patched
_render_buffer()
function is actually running, and that the finalto_render
string does NOT have trailing whitespace, but yet when rendered in Jupyter the whitespaces still exist.Can anyone provide any guidance or assistance, it would be much appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions