Make indent character configurable.

Looks nice with │ (BOX DRAWINGS LIGHT VERTICAL)

    - Add indent_character to config settings
    - Use rpadded indent_character for textwrapping
This commit is contained in:
Philip Douglass 2016-01-24 20:40:18 -05:00
parent a4783109b3
commit 91d48f85d0
2 changed files with 5 additions and 3 deletions

View file

@ -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:

View file

@ -26,6 +26,7 @@ class Journal(object):
'tagsymbols': '@',
'highlight': True,
'linewrap': 80,
'indent_character': '|',
}
self.config.update(kwargs)
# Set up date parser