Skip to content
Discussion options

You must be logged in to vote

ah i see, so u cant change the print calls bc they come from other scripts — makes sense. two options that work without touching the print code:

option 1: CSS via code_format — let the browser handle wrapping:

html = con.export_html(
    code_format=(
        '<pre style="font-family:monospace; white-space:pre-wrap; '
        'word-break:break-all; max-width:20ch;">'
        '<code style="font-family:inherit">{code}</code></pre>'
    )
)

option 2: re-record with fold — post-process the recorded text before exporting:

from rich.text import Text

# after recording is done, re-record with fold wrapping
raw_text = con.export_text()
con2 = Console(record=True, width=20)
for line in raw_text.strip

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@walkinrain2008
Comment options

@murriiii
Comment options

Answer selected by walkinrain2008
@walkinrain2008
Comment options

@walkinrain2008
Comment options

@murriiii
Comment options

@walkinrain2008
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants