1515__all__ = (
1616 "output_markdown_stream" ,
1717 "MarkdownStream" ,
18+ "ExpressMarkdownStream" ,
1819)
1920
2021StreamingContentType = Literal [
@@ -36,7 +37,7 @@ class isStreamingMessage(TypedDict):
3637 isStreaming : bool
3738
3839
39- @add_example ()
40+ @add_example ("app-core.py" )
4041class MarkdownStream :
4142 """
4243 A component for streaming markdown or HTML content.
@@ -84,53 +85,6 @@ def __init__(
8485
8586 self .on_error = on_error
8687
87- def ui (
88- self ,
89- * ,
90- content : str = "" ,
91- content_type : StreamingContentType = "markdown" ,
92- auto_scroll : bool = True ,
93- width : CssUnit = "100%" ,
94- height : CssUnit = "auto" ,
95- ) -> Tag :
96- """
97- Create a UI element for this `MarkdownStream`.
98-
99- This method is only relevant for Shiny Express. In Shiny Core, use
100- :func:`~shiny.ui.output_markdown_stream` to create the UI element.
101-
102- Parameters
103- ----------
104- content
105- Content to display when the UI element is first rendered.
106- content_type
107- The content type. Default is `"markdown"` (specifically, CommonMark).
108- Other supported options are:
109- - `"html"`: for rendering HTML content.
110- - `"text"`: for plain text.
111- - `"semi-markdown"`: for rendering markdown, but with HTML tags escaped.
112- auto_scroll
113- Whether to automatically scroll to the bottom of a scrollable container
114- when new content is added. Default is `True`.
115- width
116- The width of the UI element.
117- height
118- The height of the UI element.
119-
120- Returns
121- -------
122- Tag
123- A UI element for locating the `MarkdownStream` in the app.
124- """
125- return output_markdown_stream (
126- self .id ,
127- content = content ,
128- content_type = content_type ,
129- auto_scroll = auto_scroll ,
130- width = width ,
131- height = height ,
132- )
133-
13488 async def stream (
13589 self ,
13690 content : Union [Iterable [str ], AsyncIterable [str ]],
@@ -233,7 +187,54 @@ async def _raise_exception(self, e: BaseException):
233187 raise NotifyException (msg , sanitize = sanitize ) from e
234188
235189
236- @add_example ()
190+ @add_example ("app-express.py" )
191+ class ExpressMarkdownStream (MarkdownStream ):
192+ def ui (
193+ self ,
194+ * ,
195+ content : str = "" ,
196+ content_type : StreamingContentType = "markdown" ,
197+ auto_scroll : bool = True ,
198+ width : CssUnit = "100%" ,
199+ height : CssUnit = "auto" ,
200+ ) -> Tag :
201+ """
202+ Create a UI element for this `MarkdownStream`.
203+
204+ Parameters
205+ ----------
206+ content
207+ Content to display when the UI element is first rendered.
208+ content_type
209+ The content type. Default is `"markdown"` (specifically, CommonMark).
210+ Other supported options are:
211+ - `"html"`: for rendering HTML content.
212+ - `"text"`: for plain text.
213+ - `"semi-markdown"`: for rendering markdown, but with HTML tags escaped.
214+ auto_scroll
215+ Whether to automatically scroll to the bottom of a scrollable container
216+ when new content is added. Default is `True`.
217+ width
218+ The width of the UI element.
219+ height
220+ The height of the UI element.
221+
222+ Returns
223+ -------
224+ Tag
225+ A UI element for locating the `MarkdownStream` in the app.
226+ """
227+ return output_markdown_stream (
228+ self .id ,
229+ content = content ,
230+ content_type = content_type ,
231+ auto_scroll = auto_scroll ,
232+ width = width ,
233+ height = height ,
234+ )
235+
236+
237+ @add_example ("app-core.py" )
237238def output_markdown_stream (
238239 id : str ,
239240 * ,
@@ -246,8 +247,8 @@ def output_markdown_stream(
246247 """
247248 Create a UI element for a :class:`~shiny.ui.MarkdownStream`.
248249
249- This method is only relevant for Shiny Core. In Shiny Express, use
250- :meth:`~shiny.ui.MarkdownStream.ui` to create the UI element.
250+ This function is only relevant for Shiny Core. In Shiny Express, use
251+ :meth:`~shiny.express. ui.MarkdownStream.ui` to create the UI element.
251252
252253 Parameters
253254 ----------
0 commit comments