Functions
escape_html
1
str
▼
Escape HTML special characters.
Escapes: & " '
Uses str.translate() with a p…
escape_html
1
str
▼
def escape_html(text: str) -> str
Escape HTML special characters.
Escapes: & < > " '
Uses str.translate() with a pre-computed table for maximum performance. This is the hot path for HTML formatting — called once per token.
Performance: ~0.2µs per call for typical token lengths (5-20 chars).
Parameters
| Name | Type | Description |
|---|---|---|
text |
str |
The text to escape. |
Returns
str