Skip to content

Commit

Permalink
google keep: add support for annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Oct 2, 2024
1 parent be60d7f commit 7e57ffe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/formats/google_keep.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ This page describes how to convert notes from Google Keep to Markdown.
1. `jimmy-cli-linux takeout-20240401T160516Z-001.zip --format google_keep`
2. `jimmy-cli-linux takeout-20240401T160556Z-001.tgz --format google_keep`
4. [Import to your app](../import_instructions.md)

## Import Structure

- Each note is converted to a Markdown file.
- Links, attachments and tags are preserved.
- Annotations are appended at the end of a note.
13 changes: 12 additions & 1 deletion src/formats/google_keep.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ def convert(self, file_or_folder: Path):
imf.Resource(file_.parent.absolute() / resource_keep["filePath"])
)

# fall back to HTML if there is no plain text
body = note_keep.get("textContent", note_keep.get("textContentHtml", ""))
if (annotations := note_keep.get("annotations")) is not None:
annotations_md = ["", "", "## Annotations", ""]
for annotation in annotations:
annotations_md.append(
f"- <{annotation["url"]}>: {annotation["title"]}"
)
annotations_md.append("") # newline at the end
body += "\n".join(annotations_md)

note_imf = imf.Note(
title,
note_keep.get("textContent", note_keep.get("textContentHtml", "")),
body,
source_application=self.format,
# Labels / tags don't have a separate id. Just use the name as id.
tags=[imf.Tag(tag) for tag in tags_keep],
Expand Down
2 changes: 1 addition & 1 deletion test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def compare_dirs(dir1: Path, dir2: Path):
[["day_one/test_3/Export-Tagebuch.zip"]],
[["dynalist/test_1/dynalist-backup-2024-04-12.zip"]],
[["google_docs/test_1/takeout-20240929T124909Z-001.zip"]],
[["google_keep/test_1/takeout-20240401T160556Z-001.tgz"]],
[["google_keep/test_1/takeout-20241002T163525Z-001.tgz"]],
[["google_keep/test_2/takeout-20240920T140112Z-001.zip"]],
[["joplin/test_1/29_04_2024.jex"]],
[["jrnl/test_1/myjournal.json"]],
Expand Down

0 comments on commit 7e57ffe

Please sign in to comment.