mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Merge pull request #150 from maebert/fix-newlines
Fixes writing new lines between entries
This commit is contained in:
commit
0a2dc73716
4 changed files with 9 additions and 9 deletions
|
@ -4,6 +4,7 @@ Changelog
|
||||||
|
|
||||||
### 1.7 (December 22, 2013)
|
### 1.7 (December 22, 2013)
|
||||||
|
|
||||||
|
* __1.7.17__ Fixes writing new lines between entries
|
||||||
* __1.7.16__ Even more unicode fixes!
|
* __1.7.16__ Even more unicode fixes!
|
||||||
* __1.7.15__ More unicode fixes
|
* __1.7.15__ More unicode fixes
|
||||||
* __1.7.14__ Fix for trailing whitespaces (eg. when writing markdown code block)
|
* __1.7.14__ Fix for trailing whitespaces (eg. when writing markdown code block)
|
||||||
|
|
|
@ -25,14 +25,13 @@ class Entry:
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
"""Returns a string representation of the entry to be written into a journal file."""
|
"""Returns a string representation of the entry to be written into a journal file."""
|
||||||
date_str = self.date.strftime(self.journal.config['timeformat'])
|
date_str = self.date.strftime(self.journal.config['timeformat'])
|
||||||
title = date_str + " " + self.title
|
title = date_str + " " + self.title.rstrip("\n ")
|
||||||
if self.starred:
|
if self.starred:
|
||||||
title += " *"
|
title += " *"
|
||||||
|
|
||||||
return u"{title}{sep}{body}\n".format(
|
return u"{title}{sep}{body}\n".format(
|
||||||
title=title,
|
title=title,
|
||||||
sep="\n" if self.body else "",
|
sep="\n" if self.body.rstrip("\n ") else "",
|
||||||
body=self.body
|
body=self.body.rstrip("\n ")
|
||||||
)
|
)
|
||||||
|
|
||||||
def pprint(self, short=False):
|
def pprint(self, short=False):
|
||||||
|
@ -47,11 +46,11 @@ class Entry:
|
||||||
initial_indent="| ",
|
initial_indent="| ",
|
||||||
subsequent_indent="| ",
|
subsequent_indent="| ",
|
||||||
drop_whitespace=False)
|
drop_whitespace=False)
|
||||||
for line in self.body.rstrip().splitlines()
|
for line in self.body.rstrip(" \n").splitlines()
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
title = date_str + " " + self.title
|
title = date_str + " " + self.title.rstrip("\n ")
|
||||||
body = self.body
|
body = self.body.rstrip("\n ")
|
||||||
|
|
||||||
# Suppress bodies that are just blanks and new lines.
|
# 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)
|
has_body = len(self.body) > 20 or not all(char in (" ", "\n") for char in self.body)
|
||||||
|
|
|
@ -280,7 +280,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|[\?.]+", raw)
|
sep = re.search("\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:
|
||||||
|
|
|
@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
__title__ = 'jrnl'
|
__title__ = 'jrnl'
|
||||||
__version__ = '1.7.16'
|
__version__ = '1.7.17'
|
||||||
__author__ = 'Manuel Ebert'
|
__author__ = 'Manuel Ebert'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
||||||
|
|
Loading…
Add table
Reference in a new issue