Merge branch 'master' into 2.0-dayone-fixes

This commit is contained in:
MinchinWeb 2019-08-01 21:50:14 -06:00 committed by GitHub
commit 43a8bba8c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 1670 additions and 5632 deletions

View file

@ -99,8 +99,14 @@ class Journal(object):
def _parse(self, journal_txt):
"""Parses a journal that's stored in a string and returns a list of entries"""
# Return empty array if the journal is blank
if not journal_txt:
return []
# Initialise our current entry
entries = []
date_blob_re = re.compile("(?:^|\n)\[([^\\]]+)\] ")
last_entry_pos = 0
for match in date_blob_re.finditer(journal_txt):
@ -111,9 +117,14 @@ class Journal(object):
entries[-1].text = journal_txt[last_entry_pos:match.start()]
last_entry_pos = match.end()
entries.append(Entry.Entry(self, date=new_date))
# Finish the last entry
if entries:
entries[-1].text = journal_txt[last_entry_pos:]
# If no entries were found, treat all the existing text as an entry made now
if not entries:
entries.append(Entry.Entry(self, date=time.parse("now")))
# Fill in the text of the last entry
entries[-1].text = journal_txt[last_entry_pos:]
for entry in entries:
entry._parse_text()

View file

@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
from __future__ import absolute_import
__title__ = 'jrnl'
__version__ = '2.0.0-rc1'
__version__ = '2.0.0-rc3'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 - 2015 Manuel Ebert'

View file

@ -19,6 +19,10 @@ def parse(date_str, inclusive=False, default_hour=None, default_minute=None):
elif isinstance(date_str, datetime):
return date_str
# Don't try to parse anything with 6 or less characters. It's probably a markdown footnote
if len(date_str) <= 6:
return None
default_date = DEFAULT_FUTURE if inclusive else DEFAULT_PAST
date = None
year_present = False