mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
User defined indent character (#419)
Make indent character configurable.
This commit is contained in:
parent
dbf912c661
commit
ba05411a80
15 changed files with 18 additions and 3 deletions
|
@ -9,3 +9,4 @@ linewrap: 80
|
||||||
tagsymbols: "@"
|
tagsymbols: "@"
|
||||||
template: false
|
template: false
|
||||||
timeformat: "%Y-%m-%d %H:%M"
|
timeformat: "%Y-%m-%d %H:%M"
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
template: false
|
template: false
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ journals:
|
||||||
linewrap: 80
|
linewrap: 80
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -8,3 +8,4 @@ journals:
|
||||||
linewrap: 80
|
linewrap: 80
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -13,3 +13,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -10,3 +10,4 @@ linewrap: 80
|
||||||
password: ''
|
password: ''
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
timeformat: '%Y-%m-%d %H:%M'
|
timeformat: '%Y-%m-%d %H:%M'
|
||||||
|
indent_character: "|"
|
||||||
|
|
|
@ -74,15 +74,16 @@ class Entry:
|
||||||
"""Returns a pretty-printed version of the entry.
|
"""Returns a pretty-printed version of the entry.
|
||||||
If short is true, only print the title."""
|
If short is true, only print the title."""
|
||||||
date_str = self.date.strftime(self.journal.config['timeformat'])
|
date_str = self.date.strftime(self.journal.config['timeformat'])
|
||||||
|
indent = self.journal.config['indent_character'].rstrip() + " "
|
||||||
if not short and self.journal.config['linewrap']:
|
if not short and self.journal.config['linewrap']:
|
||||||
title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap'])
|
title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap'])
|
||||||
body = "\n".join([
|
body = "\n".join([
|
||||||
textwrap.fill(
|
textwrap.fill(
|
||||||
line,
|
line,
|
||||||
self.journal.config['linewrap'],
|
self.journal.config['linewrap'],
|
||||||
initial_indent="| ",
|
initial_indent=indent,
|
||||||
subsequent_indent="| ",
|
subsequent_indent=indent,
|
||||||
drop_whitespace=True) or "| "
|
drop_whitespace=True) or indent
|
||||||
for line in self.body.rstrip(" \n").splitlines()
|
for line in self.body.rstrip(" \n").splitlines()
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Journal(object):
|
||||||
'tagsymbols': '@',
|
'tagsymbols': '@',
|
||||||
'highlight': True,
|
'highlight': True,
|
||||||
'linewrap': 80,
|
'linewrap': 80,
|
||||||
|
'indent_character': '|',
|
||||||
}
|
}
|
||||||
self.config.update(kwargs)
|
self.config.update(kwargs)
|
||||||
# Set up date parser
|
# Set up date parser
|
||||||
|
|
|
@ -54,6 +54,7 @@ default_config = {
|
||||||
'tagsymbols': '@',
|
'tagsymbols': '@',
|
||||||
'highlight': True,
|
'highlight': True,
|
||||||
'linewrap': 79,
|
'linewrap': 79,
|
||||||
|
'indent_character': '|',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue