Merge pull request #161 from notbalanced/master

Re-fix Issue #56 by changing Regex for title.
This commit is contained in:
Manuel Ebert 2014-04-29 09:42:47 -07:00
commit cd96b37ec7
2 changed files with 24 additions and 2 deletions

View file

@ -30,3 +30,25 @@ Feature: Zapped bugs should stay dead.
""" """
2013-10-27 03:27 Some text. 2013-10-27 03:27 Some text.
""" """
Scenario: Title with an embedded period.
Given we use the config "basic.json"
When we run "jrnl 04-24-2014: Created a new website - empty.com. Hope to get a lot of traffic."
Then we should see the message "Entry added"
When we run "jrnl -1"
Then the output should be
"""
2014-04-24 09:00 Created a new website - empty.com.
| Hope to get a lot of traffic.
"""
Scenario: Title with an embedded period on DayOne journal
Given we use the config "dayone.json"
When we run "jrnl 04-24-2014: Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch."
Then we should see the message "Entry added"
When we run "jrnl -1"
Then the output should be
"""
2014-04-24 09:00 Ran 6.2 miles today in 1:02:03.
| I'm feeling sore because I forgot to stretch.
"""

View file

@ -290,7 +290,7 @@ class Journal(object):
raw = raw.replace('\\n ', '\n').replace('\\n', '\n') raw = raw.replace('\\n ', '\n').replace('\\n', '\n')
starred = False starred = False
# Split raw text into title and body # Split raw text into title and body
sep = re.search("\n|[\?!.]+ *\n?", raw) sep = re.search("\n|[\?!.]+ +\n?", raw)
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "") title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
starred = False starred = False
if not date: if not date:
@ -354,7 +354,7 @@ class DayOne(Journal):
date = dict_entry['Creation Date'] date = dict_entry['Creation Date']
date = date + timezone.utcoffset(date, is_dst=False) date = date + timezone.utcoffset(date, is_dst=False)
raw = dict_entry['Entry Text'] raw = dict_entry['Entry Text']
sep = re.search("[\n!?.]+", raw) sep = re.search("\n|[\?!.]+ +\n?", raw)
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "") title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"]) entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"])
entry.uuid = dict_entry["UUID"] entry.uuid = dict_entry["UUID"]