11from contextlib import asynccontextmanager
22from typing import AsyncIterable , Iterable , Literal , Union
33
4- from htmltools import TagChild , css
4+ from htmltools import TagChild , TagList , css
55
66from .. import _utils , reactive
77from .._deprecated import warn_deprecated
@@ -263,7 +263,7 @@ class ExpressMarkdownStream(MarkdownStream):
263263 def ui (
264264 self ,
265265 * ,
266- content : str = "" ,
266+ content : TagChild = "" ,
267267 content_type : StreamingContentType = "markdown" ,
268268 auto_scroll : bool = True ,
269269 width : CssUnit = "100%" ,
@@ -275,7 +275,9 @@ def ui(
275275 Parameters
276276 ----------
277277 content
278- Content to display when the UI element is first rendered.
278+ A string of content to display before any streaming occurs. When
279+ `content_type` isn't `"text"`, it may also be UI element(s) such as input
280+ and output bindings.
279281 content_type
280282 The content type. Default is `"markdown"` (specifically, CommonMark).
281283 Other supported options are:
@@ -309,7 +311,7 @@ def ui(
309311def output_markdown_stream (
310312 id : str ,
311313 * ,
312- content : str = "" ,
314+ content : TagChild = "" ,
313315 content_type : StreamingContentType = "markdown" ,
314316 auto_scroll : bool = True ,
315317 width : CssUnit = "100%" ,
@@ -327,7 +329,8 @@ def output_markdown_stream(
327329 A unique identifier for the UI element. This id should match the id of the
328330 :class:`~shiny.ui.MarkdownStream` instance.
329331 content
330- Some content to display before any streaming occurs.
332+ A string of content to display before any streaming occurs. When `content_type`
333+ isn't `"text"`, it may also be UI element(s) such as input and output bindings.
331334 content_type
332335 The content type. Default is "markdown" (specifically, CommonMark).
333336 Other supported options are:
@@ -342,9 +345,12 @@ def output_markdown_stream(
342345 height
343346 The height of the UI element.
344347 """
348+ ui = TagList (content ).render ()
349+
345350 return Tag (
346351 "shiny-markdown-stream" ,
347352 markdown_stream_dependency (),
353+ ui ["dependencies" ],
348354 {
349355 "style" : css (
350356 width = as_css_unit (width ),
@@ -354,5 +360,5 @@ def output_markdown_stream(
354360 "auto-scroll" : "" if auto_scroll else None ,
355361 },
356362 id = resolve_id (id ),
357- content = content ,
363+ content = ui [ "html" ] ,
358364 )
0 commit comments