Skip to content

Commit

Permalink
fix title splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
eshrh committed May 19, 2020
1 parent a3e096e commit cd6e532
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions jrnl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,7 @@

# Based on Segtok by Florian Leitner
# https://github.com/fnl/segtok
SENTENCE_SPLITTER = re.compile(
r"""
( # A sentence ends at one of two sequences:
[\'\u2019\"\u201D]? # an optional right quote,
[\]\)]* # optional closing brackets and
\s+ # a sequence of required spaces.
| # Otherwise,
\n # a sentence also terminates newlines.
)""",
re.VERBOSE,
)
SENTENCE_SPLITTER = re.compile("\n")


class UserAbort(Exception):
Expand Down Expand Up @@ -262,7 +252,7 @@ def slugify(string):

def split_title(text):
"""Splits the first sentence off from a text."""
punkt = SENTENCE_SPLITTER.search(text)
punkt = SENTENCE_SPLITTER.search(text.strip())
if not punkt:
return text, ""
return text,""
return text[: punkt.end()].strip(), text[punkt.end() :].strip()

0 comments on commit cd6e532

Please sign in to comment.