Skip to content

Commit

Permalink
don't ignore the blank lines jrnl-org#15
Browse files Browse the repository at this point in the history
  • Loading branch information
dedan committed May 14, 2012
1 parent 448f564 commit 7c3a6d0
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions jrnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,19 @@ def parse(self, journal):
current_entry = None

for line in journal.split(os.linesep):
if line:
try:
new_date = datetime.strptime(line[:date_length], self.config['timeformat'])
# make a journal entry of the current stuff first
if new_date and current_entry:
entries.append(current_entry)
# Start constructing current entry
current_entry = Entry(self, date=new_date, title=line[date_length+1:])
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.
current_entry.body += line
try:
# try to parse line as date => new entry begins
new_date = datetime.strptime(line[:date_length], self.config['timeformat'])

# parsing successfull => save old entry and create new one
if new_date and current_entry:
entries.append(current_entry)
current_entry = Entry(self, date=new_date, title=line[date_length+1:])
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.
current_entry.body += line + os.linesep

# Append last entry
if current_entry:
entries.append(current_entry)
Expand Down

0 comments on commit 7c3a6d0

Please sign in to comment.