Skip to content

Commit 376b907

Browse files
authored
🐛 Fix printing HTML from Rich output (#1055)
1 parent 2f9ce51 commit 376b907

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

typer/rich_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Extracted and modified from https://github.com/ewels/rich-click
22

33
import inspect
4+
import io
45
import sys
56
from collections import defaultdict
67
from gettext import gettext as _
@@ -717,9 +718,8 @@ def rich_to_html(input_text: str) -> str:
717718
This function does not provide a full HTML page, but can be used to insert
718719
HTML-formatted text spans into a markdown file.
719720
"""
720-
console = Console(record=True, highlight=False)
721+
console = Console(record=True, highlight=False, file=io.StringIO())
721722

722-
with console.capture():
723-
console.print(input_text, overflow="ignore", crop=False)
723+
console.print(input_text, overflow="ignore", crop=False)
724724

725725
return console.export_html(inline_styles=True, code_format="{code}").strip()

0 commit comments

Comments
 (0)