We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
When using [link=<link>]<text>[/link] to display a link in the console, it works well with local files except when these files have a space in it.
[link=<link>]<text>[/link]
link
Style.parse
file://my%20F/my%20Ffile.txt
%20F
%25F20F
from rich.console import Console path_without = r"D:\TOTO\my_dir\animals.txt" path_with = r"D:\TOTO\my_dir\file with space.txt" uri = "file://" + path_with.replace(" ", "%20F").replace("\\", "/") print(f"{uri=}") console = Console() console.print(f"Link #0: [link={path_without}]Local Path without space[/link]") console.print(f"Link #1: [link={path_with}]Local Path with space[/link]") console.print( f"Link #2: [link={uri}]Local path with space as URI[/link] (including %20F)" )
Platform
The text was updated successfully, but these errors were encountered:
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
This is an automated reply, generated by FAQtory
Sorry, something went wrong.
If we pass a URI (e.g. file://my%20F/my%20Ffile.txt), then rich replace %20F by %25F20F making the link unusable
I think it is Windows rather than Rich doing this extra encoding, for what it's worth.
from rich.console import Console from rich.text import Text text_with_encoding = r"foo%20bar%20baz" rich_text = Text.from_markup(f"[link={text_with_encoding}]Text with encoding[/link]") path_with_encoding = r"C:\Users\Tom\Documents\New%20Text%20Document.txt" rich_path = Text.from_markup(f"[link={path_with_encoding}]Path with encoding[/link]") console = Console() console.print(rich_text) console.print(rich_text.get_style_at_offset(console, 0)) console.print(rich_path) console.print(rich_path.get_style_at_offset(console, 0))
No branches or pull requests
Describe the bug
When using
[link=<link>]<text>[/link]
to display a link in the console, it works well with local files except when these files have a space in it.link
Style (the code does not enter inStyle.parse
for this)file://my%20F/my%20Ffile.txt
), then rich replace%20F
by%25F20F
making the link unusablePlatform
The text was updated successfully, but these errors were encountered: