Skip to content

Is it possible to generate html without printing to console #1183

Answered by willmcgugan
sarnikowski asked this question in Q&A
Discussion options

You must be logged in to vote

Something along these lines should work:

console = Console(record=True)
with console.capture():
    console.print("[b]Hello")

console.save_html("hello.html")

However, the most flexible way to create a console that exports HTML but never writes to the console would be to construct the Console with a file that goes nowhere. Something like this:

import os
console = Console(record=True, file=open(os.devnull, "wt"), color_system="truecolor", width=100)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sarnikowski
Comment options

Answer selected by sarnikowski
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