Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix printing HTML from Rich output #1055

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading