Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
48.13k stars 1.69k forks source link

[BUG] `soft_wrap` does nothing when printing a `Syntax` object to console #3304

Closed awgymer closed 3 months ago

awgymer commented 3 months ago

Describe the bug

I am trying to print some formatted/highlighted markdown to console with a Syntax object but it always crops the end of long lines, regardless of my settings.

Screenshot 2024-03-19 at 10 51 35 am

Platform

Click to expand Mac OS 13.5 Using terminal app with `zsh` Python 3.11 rich 13.6
github-actions[bot] commented 3 months ago

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

willmcgugan commented 3 months ago

You can set word_wrap=True on the Syntax class.

awgymer commented 3 months ago

This does not fix the issue: Screenshot 2024-03-19 at 11 53 27 am

EDIT: Turns out you need to then disable soft_wrap on the print call!

Screenshot 2024-03-19 at 11 55 19 am

That interplay is a little bit unexpected to me but hey ho

github-actions[bot] commented 3 months ago

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual