Skip to content

Commit

Permalink
Merge pull request #30 from thomaseizinger/fix/standard-notes-issues
Browse files Browse the repository at this point in the history
Fix several issues during processing of StandardNotes export
  • Loading branch information
marph91 authored Jan 5, 2025
2 parents f40c0e0 + 51effdb commit 5e20b4a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/formats/standard_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import converter
import intermediate_format as imf
import markdown_lib

import common

LOGGER = logging.getLogger("jimmy")

Expand Down Expand Up @@ -237,7 +237,8 @@ def convert(self, file_or_folder: Path):
original_id=item["uuid"],
)
for reference in item["content"]["references"]:
note_id_tag_map[reference["uuid"]].append(tag)
if uuid := reference.get("uuid"):
note_id_tag_map[uuid].append(tag)

archive_notebook = imf.Notebook("Archive")
trash_notebook = imf.Notebook("Trash")
Expand All @@ -247,7 +248,7 @@ def convert(self, file_or_folder: Path):
for item in input_json["items"]:
if item["content_type"] != "Note" or item.get("deleted", False):
continue
title = item["content"]["title"]
title = item["content"].get("title", common.unique_title())
self.logger.debug(f'Converting note "{title}"')
note_imf = imf.Note(
title,
Expand All @@ -265,8 +266,20 @@ def convert(self, file_or_folder: Path):
case "plain-text":
note_imf.body = item["content"]["text"]
case "super":
super_converter = SuperToMarkdown()
note_imf.body = super_converter.convert(item["content"]["text"])
body = item["content"]["text"]

if body:
super_converter = SuperToMarkdown()
try:
note_imf.body = super_converter.convert(item["content"]["text"])
except json.JSONDecodeError as e:
self.logger.warning(
f"Skipping Super Note '{title}' due to JSON parse error: {e}"
)
continue
else:
note_imf.body = ""

case _:
note_imf.body = item["content"]["text"]
self.logger.debug(
Expand Down

0 comments on commit 5e20b4a

Please sign in to comment.