refactor: share falsey-safe html rendering

This commit is contained in:
yaojingang
2026-06-14 14:46:44 +08:00
parent 7b210a5417
commit 6f5f4db4a7
7 changed files with 46 additions and 17 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
"""Shared HTML rendering helpers for static report generators."""
import html
from typing import Any
SCRIPT_INTERFACE = "internal-module"
SCRIPT_INTERFACE_REASON = "Used by report renderers to escape HTML while preserving meaningful falsey values."
def html_text(value: Any) -> str:
"""Escape text for HTML without dropping 0 or False values."""
return html.escape("" if value is None else str(value), quote=True)