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:
|
def prepare_title(title_of_chapter: str) -> str:
|
||||||
"""Function finalise processing/cleaning title"""
|
"""Function finalise processing/cleaning title"""
|
||||||
title_str = BeautifulSoup(title_of_chapter, features="lxml").string
|
title_str = BeautifulSoup(title_of_chapter, features="lxml").string
|
||||||
title_str = re.sub(r"([\n\t\xa0])", " ", title_str)
|
# clean extra whitespace characters ([\r\n\t\f\v ])
|
||||||
title_str = re.sub(r" +", " ", title_str).rstrip()
|
title_str = re.sub(r"[\s\xa0]", " ", title_str).strip()
|
||||||
# clean whitespace characters ([\r\n\t\f\v ])
|
|
||||||
title_str = re.sub(r"(^\s+)|(\s+$)", "", title_str)
|
|
||||||
return title_str
|
return title_str
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user