This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
"""
|
||||
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def extract_text(html_content: Optional[str]) -> str:
|
||||
def extract_text(html_content: str | None) -> str:
|
||||
"""
|
||||
Извлекает текст из HTML с помощью регулярных выражений.
|
||||
|
||||
@@ -25,10 +24,8 @@ def extract_text(html_content: Optional[str]) -> str:
|
||||
# Декодируем HTML-сущности
|
||||
text = re.sub(r"&[a-zA-Z]+;", " ", text)
|
||||
|
||||
# Заменяем несколько пробелов на один
|
||||
text = re.sub(r"\s+", " ", text).strip()
|
||||
|
||||
return text
|
||||
# Убираем лишние пробелы
|
||||
return re.sub(r"\s+", " ", text).strip()
|
||||
|
||||
|
||||
def wrap_html_fragment(fragment: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user