diff --git a/features/data/journals/simple_jrnl-1-9-5.journal b/features/data/journals/simple_jrnl-1-9-5.journal index f660305b..7bb6c5ac 100644 --- a/features/data/journals/simple_jrnl-1-9-5.journal +++ b/features/data/journals/simple_jrnl-1-9-5.journal @@ -1,3 +1,13 @@ 2010-06-10 15:00 A life without chocolate is like a bad analogy. 2013-06-10 15:40 He said "[this] is the best time to be alive". +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada +quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque +augue et venenatis facilisis. + +[2019-08-03 12:55] Some chat log or something + +Suspendisse potenti. Sed dignissim sed nisl eu consequat. Aenean ante ex, +elementum ut interdum et, mattis eget lacus. In commodo nulla nec tellus +placerat, sed ultricies metus bibendum. Duis eget venenatis erat. In at dolor +dui. diff --git a/features/regression.feature b/features/regression.feature index cfd76df1..21078a1c 100644 --- a/features/regression.feature +++ b/features/regression.feature @@ -43,15 +43,16 @@ Feature: Zapped bugs should stay dead. | Hope to get a lot of traffic. """ - Scenario: Upgrade and parse journals with square brackets - Given we use the config "upgrade_from_195.json" - When we run "jrnl -2" and enter "Y" - Then the output should contain + Scenario: Upgrade and parse journals with square brackets + Given we use the config "upgrade_from_195.json" + When we run "jrnl -9" and enter "Y" + Then the output should contain """ 2010-06-10 15:00 A life without chocolate is like a bad analogy. 2013-06-10 15:40 He said "[this] is the best time to be alive". """ + Then the journal should have 2 entries Scenario: Integers in square brackets should not be read as dates Given we use the config "brackets.yaml" diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 230171e5..cf336bdc 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -283,6 +283,7 @@ class LegacyJournal(Journal): # Initialise our current entry entries = [] current_entry = None + new_date_format_regex = re.compile(r'(^\[[^\]]+\].*?$)') for line in journal_txt.splitlines(): line = line.rstrip() try: @@ -302,7 +303,9 @@ class LegacyJournal(Journal): current_entry = Entry.Entry(self, date=new_date, text=line[date_length + 1:], starred=starred) except ValueError: # Happens when we can't parse the start of the line as an date. - # In this case, just append line to our body. + # In this case, just append line to our body (after some + # escaping for the new format). + line = new_date_format_regex.sub(r' \1', line) if current_entry: current_entry.text += line + u"\n"