Coverage for pydantic_ai_jupyter / markdown.py: 92%
12 statements
« prev ^ index » next coverage.py v7.13.2, created at 2026-01-26 11:36 -0800
« prev ^ index » next coverage.py v7.13.2, created at 2026-01-26 11:36 -0800
1"""Live-updating Markdown display for Jupyter notebooks."""
3from __future__ import annotations
5from pydantic import Field
7from .decorators import markdown
8from .models import View
11@markdown
12class Markdown(View):
13 """A live-updating Markdown display for Jupyter notebooks.
15 This class manages its own display_id internally and provides
16 methods to append content and update the display in place.
18 Example:
19 md = Markdown("# Hello")
20 md.display()
21 md.append(" World!") # Updates in place
22 """
24 content: str = Field(default="", description="The content of the Markdown display.")
26 def render(self) -> str:
27 return self.content
29 def append(self, text: str) -> None:
30 """Append text and update the display."""
31 self.content += text
32 self.update()