mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 21:46:13 +02:00
#631 Escape data in square brackets
This commit is contained in:
parent
b84f862253
commit
b260ff35b9
3 changed files with 19 additions and 5 deletions
|
@ -283,6 +283,7 @@ class LegacyJournal(Journal):
|
|||
# Initialise our current entry
|
||||
entries = []
|
||||
current_entry = None
|
||||
new_date_format_regex = re.compile(r'(^\[[^\]]+\].*?$)')
|
||||
for line in journal_txt.splitlines():
|
||||
line = line.rstrip()
|
||||
try:
|
||||
|
@ -302,7 +303,9 @@ class LegacyJournal(Journal):
|
|||
current_entry = Entry.Entry(self, date=new_date, text=line[date_length + 1:], starred=starred)
|
||||
except ValueError:
|
||||
# Happens when we can't parse the start of the line as an date.
|
||||
# In this case, just append line to our body.
|
||||
# In this case, just append line to our body (after some
|
||||
# escaping for the new format).
|
||||
line = new_date_format_regex.sub(r' \1', line)
|
||||
if current_entry:
|
||||
current_entry.text += line + u"\n"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue