Сut preparing title function

This commit is contained in:
Kiryl
2022-06-23 17:43:51 +03:00
parent 1eb59a66ac
commit 536c1d23e4

View File

@@ -79,10 +79,8 @@ def get_tags_between_chapter_marks(first_id: str, href: str, html_soup: Beautifu
def prepare_title(title_of_chapter: str) -> str:
"""Function finalise processing/cleaning title"""
title_str = BeautifulSoup(title_of_chapter, features="lxml").string
title_str = re.sub(r"([\n\t\xa0])", " ", title_str)
title_str = re.sub(r" +", " ", title_str).rstrip()
# clean whitespace characters ([\r\n\t\f\v ])
title_str = re.sub(r"(^\s+)|(\s+$)", "", title_str)
# clean extra whitespace characters ([\r\n\t\f\v ])
title_str = re.sub(r"[\s\xa0]", " ", title_str).strip()
return title_str