-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Hey @willmcgugan,
Great work on the library thanks! I have noticed that the Markdown code-block doesn't break itself when reaching line breaks, not sure if that's the expected behaviour and there is some other method to make it a new line (with proper indentation if possible) that I am not aware of.
EDIT: After going through the relevant section of rich's source code, the issue lies on this line:
https://github.com/willmcgugan/rich/blob/522f8411984abb5ff5ad749b8852835ff09b7ae5/rich/markdown.py#L180
There is no way to pass word_wrap=True which would wrap the code and not end it on line-breaks.
Currently, I have implemented a custom CodeBlock element and have been using that.
Here it works perfectly as I am not encountering line breaks
but now with just "disappear" the rest of the signature and not take it to a new line
Here, is the relevant section of my code:
if signatures is not None:
for signature in signatures:
self.console.print(Markdown(f"```py\n{signature.lstrip()}\n```"))
self.console.print("\n")Where signature represents (for the rich.console.Console) example:
class rich.console.Console(*, color_system: Optional[typing_extensions.Literal[auto, standard, 256, truecolor, windows]] = 'auto', force_terminal: Optional[bool] = None, force_jupyter: Optional[bool] = None, force_interactive: Optional[bool] = None, soft_wrap: bool = False, theme: Optional[rich.theme.Theme] = None, stderr: bool = False, file: Optional[IO[str]] = None, quiet: bool = False, width: Optional[int] = None, height: Optional[int] = None, style: Optional[Union[str, rich.style.Style]] = None, no_color: Optional[bool] = None, tab_size: int = 8, record: bool = False, markup: bool = True, emoji: bool = True, emoji_variant: Optional[typing_extensions.Literal[emoji, text]] = None, highlight: bool = True, log_time: bool = True, log_path: bool = True, log_time_format: Union[str, Callable[[datetime.datetime], rich.text.Text]] = '[%X]', highlighter: Optional[Callable[[Union[str, Text]], Text]] = <rich.highlighter.ReprHighlighter object>, legacy_windows: Optional[bool] = None, safe_box: bool = True, get_datetime: Optional[Callable[[], datetime.datetime]] = None, get_time: Optional[Callable[[], float]] = None, _environ: Optional[Mapping[str, str]] = None)

