markup
markup
#
The HTML a page is written in: one element helper, escaped text, and the document shell.
elementwrites one tag around already-rendered children;textis the only way a string becomes content, so every value passes throughhtml.escape;inline_jsonis the only way data enters a<script>.documentwraps a rendered body in the shell every page shares — charset, viewport, title, and the one stylesheet the standard components lay out with.
Attributes = Mapping[str, str | float | bool | None]
#
Attribute values: None omits the attribute, True writes it bare, False omits it.
document(title, body)
#
A complete HTML page: the shared head, title when given, body inside <main>.
Source code in capturegraph-lib/capturegraph/ui/markup.py
element(tag, attributes=None, *children)
#
<tag …>children</tag> — attributes escaped, children already HTML.
assert element("a", {"href": "../"}, text("Up")) == '<a href="../">Up</a>'
assert element("img", {"src": "files/0.jpeg", "alt": None}) == '<img src="files/0.jpeg">'
Source code in capturegraph-lib/capturegraph/ui/markup.py
inline_json(value)
#
value as a JSON literal safe inside a <script> element.
Source code in capturegraph-lib/capturegraph/ui/markup.py
picture(src, caption, href=None)
#
A <figure> of one image, captioned, wrapped in a link when href is given.
Source code in capturegraph-lib/capturegraph/ui/markup.py
text(value)
#
value as escaped text content.