diff --git a/src/epub_converter/html_epub_preprocessor.py b/src/epub_converter/html_epub_preprocessor.py index 793247c..18f8902 100644 --- a/src/epub_converter/html_epub_preprocessor.py +++ b/src/epub_converter/html_epub_preprocessor.py @@ -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