Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich.jupyter Namespace Reference

Data Structures

class  JupyterMixin
 
class  JupyterRenderable
 

Functions

str _render_segments (Iterable[Segment] segments)
 
None display (Iterable[Segment] segments, str text)
 
None print (*Any args, **Any kwargs)
 

Variables

str JUPYTER_HTML_FORMAT
 

Function Documentation

◆ _render_segments()

str _render_segments ( Iterable[Segment segments)
protected

Definition at line 59 of file jupyter.py.

59def _render_segments(segments: Iterable[Segment]) -> str:
60 def escape(text: str) -> str:
61 """Escape html."""
62 return text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
63
64 fragments: List[str] = []
65 append_fragment = fragments.append
66 theme = DEFAULT_TERMINAL_THEME
67 for text, style, control in Segment.simplify(segments):
68 if control:
69 continue
70 text = escape(text)
71 if style:
72 rule = style.get_html_style(theme)
73 text = f'<span style="{rule}">{text}</span>' if rule else text
74 if style.link:
75 text = f'<a href="{style.link}" target="_blank">{text}</a>'
76 append_fragment(text)
77
78 code = "".join(fragments)
79 html = JUPYTER_HTML_FORMAT.format(code=code)
80
81 return html
82
83
for i

References i.

Referenced by JupyterMixin._repr_mimebundle_(), and pip._vendor.rich.jupyter.display().

Here is the caller graph for this function:

◆ display()

None display ( Iterable[Segment segments,
str  text 
)
Render segments to Jupyter.

Definition at line 84 of file jupyter.py.

84def display(segments: Iterable[Segment], text: str) -> None:
85 """Render segments to Jupyter."""
86 html = _render_segments(segments)
87 jupyter_renderable = JupyterRenderable(html, text)
88 try:
89 from IPython.display import display as ipython_display
90
91 ipython_display(jupyter_renderable)
92 except ModuleNotFoundError:
93 # Handle the case where the Console has force_jupyter=True,
94 # but IPython is not installed.
95 pass
96
97

References pip._vendor.rich.jupyter._render_segments(), and i.

Here is the call graph for this function:

◆ print()

None print ( *Any  args,
**Any  kwargs 
)
Proxy for Console print.

Definition at line 98 of file jupyter.py.

98def print(*args: Any, **kwargs: Any) -> None:
99 """Proxy for Console print."""
100 console = get_console()
101 return console.print(*args, **kwargs)

References i.

Variable Documentation

◆ JUPYTER_HTML_FORMAT

str JUPYTER_HTML_FORMAT
Initial value:
1= """\
2<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">{code}</pre>
3"""

Definition at line 13 of file jupyter.py.