"""
@@ -153,6 +153,55 @@ def _svg_text(x: float, y: float, text: str, *, size: int = 14, weight: str = "4
return f'
'
+def _svg_multiline_text(
+ x: float,
+ y: float,
+ text: str,
+ *,
+ max_chars: int = 42,
+ line_height: int = 16,
+ size: int = 14,
+ weight: str = "400",
+ fill: str = SVG_INK,
+ anchor: str = "start",
+) -> str:
+ words = text.split()
+ if not words:
+ return ""
+
+ lines: list[str] = []
+ current = words[0]
+ for word in words[1:]:
+ candidate = f"{current} {word}"
+ if len(candidate) <= max_chars:
+ current = candidate
+ else:
+ lines.append(current)
+ current = word
+ lines.append(current)
+
+ return "".join(
+ _svg_text(
+ x,
+ y + index * line_height,
+ line,
+ size=size,
+ weight=weight,
+ fill=fill,
+ anchor=anchor,
+ )
+ for index, line in enumerate(lines)
+ )
+
+
+def _svg_canvas_open(width: int, height: int) -> str:
+ return (
+ f'