mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Adds word wrap support.
This commit is contained in:
parent
56c974f1dd
commit
f7eee0fa76
3 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
* [Improved] Supports a config option for setting word wrap.
|
||||||
|
|
||||||
### 0.3.0 (May 24, 2012)
|
### 0.3.0 (May 24, 2012)
|
||||||
|
|
||||||
* [Fixed] Dates such as "May 3" will now be interpreted as being in the past if the current day is at least 28 days in the future
|
* [Fixed] Dates such as "May 3" will now be interpreted as being in the past if the current day is at least 28 days in the future
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import textwrap
|
||||||
|
|
||||||
class Entry:
|
class Entry:
|
||||||
def __init__(self, journal, date=None, title="", body=""):
|
def __init__(self, journal, date=None, title="", body=""):
|
||||||
|
@ -19,7 +20,10 @@ class Entry:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
date_str = self.date.strftime(self.journal.config['timeformat'])
|
date_str = self.date.strftime(self.journal.config['timeformat'])
|
||||||
body_wrapper = "\n" if self.body else ""
|
body_wrapper = "\n" if self.body else ""
|
||||||
body = body_wrapper + self.body.strip()
|
if self.journal.config['linewrap']:
|
||||||
|
body = body_wrapper + textwrap.fill(self.body, self.journal.config['linewrap'])
|
||||||
|
else:
|
||||||
|
body = body_wrapper + self.body.strip()
|
||||||
space = "\n"
|
space = "\n"
|
||||||
|
|
||||||
return "%(date)s %(title)s %(body)s %(space)s" % {
|
return "%(date)s %(title)s %(body)s %(space)s" % {
|
||||||
|
|
|
@ -26,6 +26,7 @@ default_config = {
|
||||||
'timeformat': "%Y-%m-%d %H:%M",
|
'timeformat': "%Y-%m-%d %H:%M",
|
||||||
'tagsymbols': '@',
|
'tagsymbols': '@',
|
||||||
'highlight': True,
|
'highlight': True,
|
||||||
|
'linewrap': 80,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue