mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Suppress empty bodies in prettyprinting
This commit is contained in:
parent
e21cdd7e69
commit
7a8b847bd7
1 changed files with 5 additions and 2 deletions
|
@ -46,10 +46,13 @@ class Entry:
|
||||||
title = date_str + " " + self.title
|
title = date_str + " " + self.title
|
||||||
body = self.body.strip()
|
body = self.body.strip()
|
||||||
|
|
||||||
|
# Suppress bodies that are just blanks and new lines.
|
||||||
|
has_body = len(self.body) > 20 or not all(char in (" ", "\n") for char in self.body)
|
||||||
|
|
||||||
return "{title}{sep}{body}\n".format(
|
return "{title}{sep}{body}\n".format(
|
||||||
title=title,
|
title=title,
|
||||||
sep="\n" if self.body else "",
|
sep="\n" if has_body else "",
|
||||||
body=body
|
body=body if has_body else "",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue