12 lines
331 B
Python
12 lines
331 B
Python
import re
|
|
from typing import Any, Optional
|
|
|
|
|
|
def strip_html(value: Any) -> Optional[str]:
|
|
"""Remove HTML tags from a string, returning plain text for SEO fields."""
|
|
if not value:
|
|
return None
|
|
val_str = str(value).strip()
|
|
if not val_str:
|
|
return None
|
|
return re.sub(r"<[^>]+>", "", val_str).strip()
|