Correctly extract titles with multiple line breaks

Since the location of the separator was computed on the `text.lstrip()`
but the function returned the substring of `text` the title would be cut
off.
This commit is contained in:
Thibaud Chupin 2024-03-23 21:11:29 +01:00
parent c8c49b1ba2
commit 070350febb

View file

@ -223,7 +223,8 @@ SENTENCE_SPLITTER_ONLY_NEWLINE = re.compile("\n")
def split_title(text: str) -> tuple[str, str]: def split_title(text: str) -> tuple[str, str]:
"""Splits the first sentence off from a text.""" """Splits the first sentence off from a text."""
sep = SENTENCE_SPLITTER_ONLY_NEWLINE.search(text.lstrip()) text = text.lstrip()
sep = SENTENCE_SPLITTER_ONLY_NEWLINE.search(text)
if not sep: if not sep:
sep = SENTENCE_SPLITTER.search(text) sep = SENTENCE_SPLITTER.search(text)
if not sep: if not sep: