forked from LiveCarta/BookConverter
Сut preparing title function
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user