Skip to content

Commit

Permalink
🐛 Fix printing HTML from Rich output (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo authored Nov 18, 2024
1 parent 2f9ce51 commit 376b907
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions typer/rich_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Extracted and modified from https://github.com/ewels/rich-click

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

with console.capture():
console.print(input_text, overflow="ignore", crop=False)
console.print(input_text, overflow="ignore", crop=False)

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

0 comments on commit 376b907

Please sign in to comment.