Convert a small HTML fragment into plain text.
(value: str)
| 586 | |
| 587 | |
| 588 | def _strip_html(value: str) -> str: |
| 589 | """Convert a small HTML fragment into plain text.""" |
| 590 | if not value: |
| 591 | return "" |
| 592 | without_scripts = re.sub(r"(?is)<(script|style)[^>]*>.*?</\1>", " ", value) |
| 593 | plain = re.sub(r"(?s)<[^>]+>", " ", without_scripts) |
| 594 | return _collapse_whitespace(html.unescape(plain)) |
| 595 | |
| 596 | |
| 597 | def _extract_first_group(pattern: str, text: str) -> str: |
no test coverage detected