diff --git a/features/core.feature b/features/core.feature index 057db399..e6549f83 100644 --- a/features/core.feature +++ b/features/core.feature @@ -26,6 +26,18 @@ Feature: Basic reading and writing to a journal | There is a blank line above this. """ + Scenario: Multiline entry with punctuation + Given we use the config "basic.yaml" + When we run "jrnl This is. the title\\n This is the second line" + and we run "jrnl -n 1" + Then the output should contain "This is. the title" + + Scenario: Single line entry with punctuation + Given we use the config "basic.yaml" + When we run "jrnl This is. the title" + and we run "jrnl -n 1" + Then the output should contain "| the title" + Scenario: Writing an entry from command line Given we use the config "basic.yaml" When we run "jrnl 23 july 2013: A cold and stormy day. I ate crisps on the sofa." diff --git a/jrnl/util.py b/jrnl/util.py index a412bb81..db86a5ee 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -34,11 +34,10 @@ SENTENCE_SPLITTER = re.compile( [\'\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_ONLY_NEWLINE = re.compile("\n") class UserAbort(Exception): @@ -281,7 +280,9 @@ def slugify(string): def split_title(text): """Splits the first sentence off from a text.""" - punkt = SENTENCE_SPLITTER.search(text) - if not punkt: - return text, "" - return text[: punkt.end()].strip(), text[punkt.end() :].strip() + sep = SENTENCE_SPLITTER_ONLY_NEWLINE.search(text.lstrip()) + if not sep: + sep = SENTENCE_SPLITTER.search(text) + if not sep: + return text, "" + return text[: sep.end()].strip(), text[sep.end() :].strip()