mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Adds word wrap support.
This commit is contained in:
parent
22b3da5f89
commit
7ae9f2bed2
3 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
* [Improved] Supports a config option for setting word wrap.
|
||||
|
||||
### 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
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
class Entry:
|
||||
def __init__(self, journal, date=None, title="", body=""):
|
||||
|
@ -19,7 +20,10 @@ class Entry:
|
|||
def __str__(self):
|
||||
date_str = self.date.strftime(self.journal.config['timeformat'])
|
||||
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"
|
||||
|
||||
return "%(date)s %(title)s %(body)s %(space)s" % {
|
||||
|
|
|
@ -26,6 +26,7 @@ default_config = {
|
|||
'timeformat': "%Y-%m-%d %H:%M",
|
||||
'tagsymbols': '@',
|
||||
'highlight': True,
|
||||
'linewrap': 80,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue