From ba05411a8062d80614cdcf284d312d86db57174b Mon Sep 17 00:00:00 2001 From: Philip Douglass Date: Sat, 16 Apr 2016 02:00:49 -0400 Subject: [PATCH] User defined indent character (#419) Make indent character configurable. --- features/data/configs/basic.yaml | 1 + features/data/configs/bug153.yaml | 1 + features/data/configs/bug343.yaml | 1 + features/data/configs/dayone.yaml | 1 + features/data/configs/empty_folder.yaml | 1 + features/data/configs/encrypted.yaml | 1 + features/data/configs/encrypted_old.yaml | 1 + features/data/configs/markdown-headings-335.yaml | 1 + features/data/configs/multiple.yaml | 1 + features/data/configs/tags-216.yaml | 1 + features/data/configs/tags-237.yaml | 1 + features/data/configs/tags.yaml | 1 + jrnl/Entry.py | 7 ++++--- jrnl/Journal.py | 1 + jrnl/install.py | 1 + 15 files changed, 18 insertions(+), 3 deletions(-) diff --git a/features/data/configs/basic.yaml b/features/data/configs/basic.yaml index f6ab1a67..9111b561 100644 --- a/features/data/configs/basic.yaml +++ b/features/data/configs/basic.yaml @@ -9,3 +9,4 @@ linewrap: 80 tagsymbols: "@" template: false timeformat: "%Y-%m-%d %H:%M" +indent_character: "|" diff --git a/features/data/configs/bug153.yaml b/features/data/configs/bug153.yaml index eb71edd3..765185c3 100644 --- a/features/data/configs/bug153.yaml +++ b/features/data/configs/bug153.yaml @@ -10,3 +10,4 @@ password: '' tagsymbols: '@' template: false timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/bug343.yaml b/features/data/configs/bug343.yaml index 6e6982a7..a4e25d8a 100644 --- a/features/data/configs/bug343.yaml +++ b/features/data/configs/bug343.yaml @@ -10,3 +10,4 @@ journals: linewrap: 80 tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/dayone.yaml b/features/data/configs/dayone.yaml index 507a3978..e7331733 100644 --- a/features/data/configs/dayone.yaml +++ b/features/data/configs/dayone.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/empty_folder.yaml b/features/data/configs/empty_folder.yaml index 6d6a4ca2..ee401ada 100644 --- a/features/data/configs/empty_folder.yaml +++ b/features/data/configs/empty_folder.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/encrypted.yaml b/features/data/configs/encrypted.yaml index dd96a58c..254b81d9 100644 --- a/features/data/configs/encrypted.yaml +++ b/features/data/configs/encrypted.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/encrypted_old.yaml b/features/data/configs/encrypted_old.yaml index 5324057c..bc7b1440 100644 --- a/features/data/configs/encrypted_old.yaml +++ b/features/data/configs/encrypted_old.yaml @@ -8,3 +8,4 @@ journals: linewrap: 80 tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/markdown-headings-335.yaml b/features/data/configs/markdown-headings-335.yaml index d57f5a3d..dafed64b 100644 --- a/features/data/configs/markdown-headings-335.yaml +++ b/features/data/configs/markdown-headings-335.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/multiple.yaml b/features/data/configs/multiple.yaml index c42719c0..1bbb872f 100644 --- a/features/data/configs/multiple.yaml +++ b/features/data/configs/multiple.yaml @@ -13,3 +13,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/tags-216.yaml b/features/data/configs/tags-216.yaml index 772d892c..73523c50 100644 --- a/features/data/configs/tags-216.yaml +++ b/features/data/configs/tags-216.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/tags-237.yaml b/features/data/configs/tags-237.yaml index 93d9c142..2b360f6f 100644 --- a/features/data/configs/tags-237.yaml +++ b/features/data/configs/tags-237.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/features/data/configs/tags.yaml b/features/data/configs/tags.yaml index 210c609d..51a2b8b2 100644 --- a/features/data/configs/tags.yaml +++ b/features/data/configs/tags.yaml @@ -10,3 +10,4 @@ linewrap: 80 password: '' tagsymbols: '@' timeformat: '%Y-%m-%d %H:%M' +indent_character: "|" diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 7ee53d07..338a271a 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -74,15 +74,16 @@ class Entry: """Returns a pretty-printed version of the entry. If short is true, only print the title.""" date_str = self.date.strftime(self.journal.config['timeformat']) + indent = self.journal.config['indent_character'].rstrip() + " " 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, self.journal.config['linewrap'], - initial_indent="| ", - subsequent_indent="| ", - drop_whitespace=True) or "| " + initial_indent=indent, + subsequent_indent=indent, + drop_whitespace=True) or indent for line in self.body.rstrip(" \n").splitlines() ]) else: diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 517076ba..f107e09e 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -26,6 +26,7 @@ class Journal(object): 'tagsymbols': '@', 'highlight': True, 'linewrap': 80, + 'indent_character': '|', } self.config.update(kwargs) # Set up date parser diff --git a/jrnl/install.py b/jrnl/install.py index 2426aea6..7cc8f880 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -54,6 +54,7 @@ default_config = { 'tagsymbols': '@', 'highlight': True, 'linewrap': 79, + 'indent_character': '|', }