From 1ea5255aa0419ca3c1a02ec81528b8e904115d66 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Fri, 28 Aug 2015 12:08:25 -0400 Subject: [PATCH 1/2] Made line wrapping more clever about whitespace --- jrnl/Entry.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 66b32f6c..b5e1965a 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -48,11 +48,10 @@ class Entry: if not short and self.journal.config['linewrap']: title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap']) body = "\n".join([ - textwrap.fill((line + " ") if (len(line) == 0) else line, + textwrap.fill(line, self.journal.config['linewrap'], initial_indent="| ", - subsequent_indent="| ", - drop_whitespace=False) + subsequent_indent="| ") or "|" for line in self.body.rstrip(" \n").splitlines() ]) else: From 8c5c47f2ca5a853c3f329faf31ac6ee72b4e4b36 Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Fri, 28 Aug 2015 12:19:29 -0400 Subject: [PATCH 2/2] =?UTF-8?q?Made=20indent=20character=20configurable.?= =?UTF-8?q?=20Looks=20nice=20with=20=E2=94=82=20(BOX=20DRAWINGS=20LIGHT=20?= =?UTF-8?q?VERTICAL)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jrnl/Entry.py | 5 +++-- jrnl/Journal.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jrnl/Entry.py b/jrnl/Entry.py index b5e1965a..fb85ed0e 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -50,8 +50,9 @@ class Entry: body = "\n".join([ textwrap.fill(line, self.journal.config['linewrap'], - initial_indent="| ", - subsequent_indent="| ") or "|" + initial_indent=self.journal.config['indent'] + " ", + subsequent_indent=self.journal.config['indent'] + " ") + or self.journal.config['indent'] for line in self.body.rstrip(" \n").splitlines() ]) else: diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 92a6774f..76e618a5 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -29,6 +29,7 @@ class Journal(object): 'tagsymbols': '@', 'highlight': True, 'linewrap': 80, + 'indent': "|" } self.config.update(kwargs) # Set up date parser