yera.runtime.handlers.markdown.htmx

Streaming markdown handler for the HTMX target.

Symbols

class HTMXMarkdownHandler — Render a streaming Markdown block through incremental morph swaps.

HTMXMarkdownHandler

Inherits: BaseHTMXHandler

Render a streaming Markdown block through incremental morph swaps.

Settled Markdown prefixes are committed as immutable segments while the live tail is repeatedly rendered and replaced. A trailing table is rendered through the shared Markdown renderer as soon as its header and delimiter are complete, while an unfinished final row is withheld until more input arrives. This keeps streaming output stable without giving tables, mathematics, or other inline Markdown a separate rendering path.

Methods

__init__ — Initialize web Markdown rendering with empty streaming state.
__exit__ — Flush the tail unthrottled and unconditionally.
push — Append a chunk; publish at most one swap every ``_MIN_FRAME_S``.

HTMXMarkdownHandler.__init__

__init__(
    web_render: WebRenderContext,
) → None

Initialize web Markdown rendering with empty streaming state.

Parameters

web_render
type: WebRenderContext

Context whose publisher receives rendered HTMX fragments.

HTMXMarkdownHandler.__exit__

__exit__(
    exc_type: type[BaseException] | None,
    exc_val: BaseException | None,
    exc_tb: TracebackType | None,
)

Flush the tail unthrottled and unconditionally.

The last chunk's swap may have been coalesced away, and render_streaming_markdown holds back an in-progress table row that only a full render releases.

Parameters

exc_type
type: type[BaseException] | None

Type of exception leaving the context, if any.

exc_val
type: BaseException | None

Exception leaving the context, if any.

exc_tb
type: TracebackType | None

Traceback associated with the exception, if any.

Returns

The base handler's exception-suppression decision.

HTMXMarkdownHandler.push

push(
    event: OutputEvent,
) → None

Append a chunk; publish at most one swap every _MIN_FRAME_S.

Parameters

event
type: OutputEvent

An output event carrying MarkdownData.

Raises

TypeError

If the event data is not MarkdownData.