Skip to content

Commit

Permalink
evernote: fix (some) unneeded spaces in lists
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Nov 27, 2024
1 parent 5e08739 commit db8aac4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/markdown_lib/evernote.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def end(self, tag: str):
match tag:
case "a":
# internal note link
if (prepend := self.active_link.get("prepend")):
if prepend := self.active_link.get("prepend"):
self.md.extend(prepend)
title = self.active_link.get("title")
url = self.active_link["href"]
Expand All @@ -331,7 +331,7 @@ def end(self, tag: str):
else:
# normal link
self.md.append(f"[{title}]({url})")
if (append := self.active_link.get("append")):
if append := self.active_link.get("append"):
self.md.extend(append)
self.active_link = {}
case (
Expand Down Expand Up @@ -452,6 +452,17 @@ def data(self, data: str):
# - if the previous data contains only whitespace, too
return

if (
self.active_lists
and self.md
and any(
self.md[-1].endswith(bullet)
for bullet in ["- [x] ", "- [ ] ", "- ", "1. "]
)
):
# Normalize whitespaces at the start of list items.
data = data.lstrip()

if self.encryption is not None:
# https://help.evernote.com/hc/en-us/articles/208314128-What-type-of-encryption-does-Evernote-use
# https://soundly.me/decoding-the-Evernote-en-crypt-field-payload/
Expand Down

0 comments on commit db8aac4

Please sign in to comment.