File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -2170,10 +2170,10 @@ def _markdown_display(self, echo: EchoOptions) -> ChatMarkdownDisplay:
21702170 return ChatMarkdownDisplay (MockMarkdownDisplay (), self )
21712171
21722172 # rich does a lot to detect a notebook environment, but it doesn't
2173- # detect Quarto (at least not yet).
2173+ # detect Quarto, or a Positron notebook
21742174 from rich .console import Console
21752175
2176- is_web = Console ().is_jupyter or os . getenv ( "QUARTO_PYTHON" , None ) is not None
2176+ is_web = Console ().is_jupyter or is_quarto () or is_positron_notebook ()
21772177
21782178 opts = self ._echo_options
21792179
@@ -2421,3 +2421,17 @@ class ToolFailureWarning(RuntimeWarning):
24212421
24222422# By default warnings are shown once; we want to always show them.
24232423warnings .simplefilter ("always" , ToolFailureWarning )
2424+
2425+
2426+ def is_quarto ():
2427+ return os .getenv ("QUARTO_PYTHON" , None ) is not None
2428+
2429+
2430+ def is_positron_notebook ():
2431+ try :
2432+ get_ipython # type: ignore[name-defined]
2433+ except NameError :
2434+ return False
2435+ ipython = get_ipython () # type: ignore[name-defined]
2436+ session_mode = getattr (ipython , "session_mode" , None )
2437+ return session_mode == "notebook"
You can’t perform that action at this time.
0 commit comments