Clean text by removing HTML tags and excessive whitespace
(text)
| 13 | |
| 14 | |
| 15 | def clean_text(text): |
| 16 | """Clean text by removing HTML tags and excessive whitespace""" |
| 17 | if not text: |
| 18 | return "" |
| 19 | # Remove HTML tags |
| 20 | text = re.sub(r'<[^>]+>', '', str(text)) |
| 21 | # Decode HTML entities |
| 22 | text = html.unescape(text) |
| 23 | # Replace quotes |
| 24 | text = text.replace(""", "\"").replace("&", "&") |
| 25 | # Remove excessive whitespace |
| 26 | text = re.sub(r'\s+', ' ', text) |
| 27 | return text.strip() |
| 28 | |
| 29 | |
| 30 | def check_path(path): |
no outgoing calls
no test coverage detected