mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 21:46:13 +02:00
Refractored exporting
This commit is contained in:
parent
af2c592700
commit
44c1f55dea
3 changed files with 28 additions and 22 deletions
|
@ -149,26 +149,6 @@ class Journal:
|
|||
pp)
|
||||
return pp
|
||||
|
||||
def to_json(self):
|
||||
"""Returns a JSON representation of the Journal."""
|
||||
return json.dumps([e.to_dict() for e in self.entries], indent=2)
|
||||
|
||||
def to_md(self):
|
||||
"""Returns a markdown representation of the Journal"""
|
||||
out = []
|
||||
year, month = -1, -1
|
||||
for e in self.entries:
|
||||
if not e.date.year == year:
|
||||
year = e.date.year
|
||||
out.append(str(year))
|
||||
out.append("=" * len(str(year)) + "\n")
|
||||
if not e.date.month == month:
|
||||
month = e.date.month
|
||||
out.append(e.date.strftime("%B"))
|
||||
out.append('-' * len(e.date.strftime("%B")) + "\n")
|
||||
out.append(e.to_md())
|
||||
return "\n".join(out)
|
||||
|
||||
def __repr__(self):
|
||||
return "<Journal with %d entries>" % len(self.entries)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue