Fixes writing new lines between entries

This commit is contained in:
Manuel Ebert 2014-03-31 12:37:37 -07:00
parent 3317cf0109
commit 6a5a98919e
4 changed files with 9 additions and 9 deletions

View file

@ -4,6 +4,7 @@ Changelog
### 1.7 (December 22, 2013)
* __1.7.17__ Fixes writing new lines between entries
* __1.7.16__ Even more unicode fixes!
* __1.7.15__ More unicode fixes
* __1.7.14__ Fix for trailing whitespaces (eg. when writing markdown code block)

View file

@ -25,14 +25,13 @@ class Entry:
def __unicode__(self):
"""Returns a string representation of the entry to be written into a journal file."""
date_str = self.date.strftime(self.journal.config['timeformat'])
title = date_str + " " + self.title
title = date_str + " " + self.title.rstrip("\n ")
if self.starred:
title += " *"
return u"{title}{sep}{body}\n".format(
title=title,
sep="\n" if self.body else "",
body=self.body
sep="\n" if self.body.rstrip("\n ") else "",
body=self.body.rstrip("\n ")
)
def pprint(self, short=False):
@ -47,11 +46,11 @@ class Entry:
initial_indent="| ",
subsequent_indent="| ",
drop_whitespace=False)
for line in self.body.rstrip().splitlines()
for line in self.body.rstrip(" \n").splitlines()
])
else:
title = date_str + " " + self.title
body = self.body
title = date_str + " " + self.title.rstrip("\n ")
body = self.body.rstrip("\n ")
# Suppress bodies that are just blanks and new lines.
has_body = len(self.body) > 20 or not all(char in (" ", "\n") for char in self.body)

View file

@ -280,7 +280,7 @@ class Journal(object):
raw = raw.replace('\\n ', '\n').replace('\\n', '\n')
starred = False
# Split raw text into title and body
sep = re.search("\n|[\?.]+", raw)
sep = re.search("\n|[\?!.]+ *", raw)
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
starred = False
if not date:

View file

@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
from __future__ import absolute_import
__title__ = 'jrnl'
__version__ = '1.7.16'
__version__ = '1.7.17'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'