Skip to content

[REQUEST] Jupyter-safe "strict text" mode for Console #3896

@clemisch

Description

@clemisch

How would you improve Rich?

I would like to request a supported option for rich.console.Console that forces strict plain-text output in Jupyter notebooks while retaining the structured features of Console.log such as time and path columns.

The key capability would be the ability to disable all HTML rendering, ANSI styling, highlighting, and especially OSC 8 hyperlinks, without disabling the display of the file path itself.

Something like:

console = Console(
    force_jupyter=False,     # use text output
    strict_text=True,        # no HTML, no ANSI, no hyperlinks
    log_time=True,
    log_path=True
)

Expected output: clean single-spaced text logs in Jupyter, with the time and file path shown as plain ASCII text. No HTML blocks, no visible escape sequences, and no OSC 8 hyperlinks.

Currently the only way to get this behavior is to monkey-patch the private _log_render method to force link_path=None, which is brittle:

_original = console._log_render

def _nologlinks(self, *args, **kwargs):
    kwargs["link_path"] = None
    return _original(*args, **kwargs)

console._log_render = types.MethodType(_nologlinks, console)

What problem does it solve for you?

In Jupyter, rich’s HTML output produces large vertical spacing between console.log calls because each call becomes a separate <pre> block with notebook CSS margins.
Forcing terminal output (force_jupyter=False) produces ANSI and OSC 8 hyperlink escape sequences that Jupyter does not interpret correctly, resulting in visible escape codes or duplicated-looking lines.

(The OSC 8 hyperlinks are not useful anyway in remote-server notebook environments because the paths do not exist on the client machine.)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions