Skip to content

Commit ffd3f8a

Browse files
committed
add support for anytype
1 parent a5090f8 commit ffd3f8a

File tree

14 files changed

+69
-7
lines changed

14 files changed

+69
-7
lines changed

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ jobs:
6161
./dist/jimmy-cli* test/data/test_data/qownnotes/test_1/note_folder --format qownnotes
6262
# pyyaml module
6363
./dist/jimmy-cli* test/data/test_data/rednotebook/test_2/RedNotebook-Backup-2024-09-15.zip --format rednotebook
64+
# anytype module
65+
./dist/jimmy-cli* test/data/test_data/anytype/test_1/Anytype.20241112.175339.64 --format anytype

docs/contributing/more_note_apps.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Loose collection of note apps/messengers/wikis/formats that could be implemented
44
| --- | --- | --- |
55
| [Affine](https://github.com/toeverything/AFFiNE) | [doc](https://docs.affine.pro/docs/settings) | |
66
| [Agenda](https://agenda.com/) | [doc](https://agenda.community/t/sharing-import-export-and-printing/56) | apple only |
7-
| [Anytype](https://anytype.io/) | | |
87
| [Apple Notes](https://www.icloud.com/notes) | [script](https://github.com/mattrose/AppleNotes2Joplin) | apple only |
98
| [Appflowy](https://appflowy.io/) | [seems to be not possible yet](https://github.com/AppFlowy-IO/AppFlowy/issues/4387) | |
109
| [Asana](https://asana.com/) | [doc](https://help.taskade.com/en/articles/8958607-import-from-asana) | |

docs/formats/anytype.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This page describes how to convert notes from ColorNote to Markdown.
2+
3+
## General Information
4+
5+
- [Website](https://anytype.io/)
6+
- Typical extension: Folder
7+
8+
## Instructions
9+
10+
1. Export as described [at the website](https://doc.anytype.io/anytype-docs/basics/import-export)
11+
1. Choose "Any-Block"
12+
2. [Install jimmy](../index.md#installation)
13+
3. Convert to Markdown. Example: `jimmy-cli-linux Anytype.20241112.175339.64 --format anytype`
14+
4. [Import to your app](../import_instructions.md)
15+
16+
## Acknowledgements
17+
18+
The converter is based on <https://github.com/jfcostello/AnyBlock-To-Markdown>. Thanks for developing it!
19+
20+
## Known Limitations
21+
22+
Images and attachments aren't converted.

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Export data from your app and convert it to Markdown. For details, click on the
2424

2525
||||||
2626
| :--- | :---: | :---: | :---: | :---: |
27-
| **A** | <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Anki-icon.svg/240px-Anki-icon.svg.png" style="height:100px;max-width:100px;"><br>[Anki](https://marph91.github.io/jimmy/formats/anki/) |
27+
| **A** | <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Anki-icon.svg/240px-Anki-icon.svg.png" style="height:100px;max-width:100px;"><br>[Anki](https://marph91.github.io/jimmy/formats/anki/) | <img src="https://raw.githubusercontent.com/anyproto/anytype-ts/refs/heads/main/src/img/logo/symbol.svg" style="height:100px;max-width:100px;"><br>[Anytype](https://marph91.github.io/jimmy/formats/anytype/) |
2828
| **B** | <img src="https://bear.app/images/logo.png" style="height:100px;max-width:100px;"><br>[Bear](https://marph91.github.io/jimmy/formats/bear/) |
2929
| **C** | <img src="https://raw.githubusercontent.com/CacherApp/cacher-cli/e241f06867dba740131db5314ef7fe279135baf6/images/cacher-icon.png" style="height:100px;max-width:100px;"><br>[Cacher](https://marph91.github.io/jimmy/formats/cacher/) | <img src="https://raw.githubusercontent.com/giuspen/cherrytree/c822b16681b002b8882645d8d1e8f109514ddb58/icons/cherrytree.svg" style="height:100px;max-width:100px;"><br>[CherryTree](https://marph91.github.io/jimmy/formats/cherrytree/) | <img src="https://avatars.githubusercontent.com/u/53916365?s=200&v=4" style="height:100px;max-width:100px;"><br>[Clipto](https://marph91.github.io/jimmy/formats/clipto/) | <img src="https://www.colornote.com/wp-content/uploads/2016/05/cropped-favicon.png" style="height:100px;max-width:100px;"><br>[ColorNote](https://marph91.github.io/jimmy/formats/colornote/) |
3030
| **D** | <img src="https://seeklogo.com/images/D/day-one-logo-F4CA245C26-seeklogo.com.png" style="height:100px;max-width:100px;"><br>[Day&nbsp;One](https://marph91.github.io/jimmy/formats/day_one/) | <img src="https://images.saasworthy.com/dynalist_5288_logo_1576239391_xhkcg.jpg" style="height:100px;max-width:100px;"><br>[Dynalist](https://marph91.github.io/jimmy/formats/dynalist/) |

jimmy_cli.spec

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ from PyInstaller.utils.hooks import collect_data_files
33

44
# pypandoc: https://github.com/orgs/pyinstaller/discussions/8387
55
datas = [(".version", ".")]
6-
datas += collect_data_files('pypandoc')
6+
datas += collect_data_files("anyblock_exporter")
7+
datas += collect_data_files("pypandoc")
78

89

910
# Generate list of hidden imports

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ nav:
5353
- Formats:
5454
- Default Import: formats/default.md
5555
- Anki: formats/anki.md
56+
- Anytype: formats/anytype.md
5657
- Bear: formats/bear.md
5758
- Cacher: formats/cacher.md
5859
- CherryTree: formats/cherrytree.md

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extra_checks = true
1818
disable_error_code = "attr-defined"
1919
[[tool.mypy.overrides]]
2020
module = [
21+
"anyblock_exporter",
2122
"enlighten",
2223
"frontmatter",
2324
"puremagic",

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Export data from your app and convert it to Markdown. For details, click on the
2828

2929
||||||
3030
| :--- | :---: | :---: | :---: | :---: |
31-
| **A** | <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Anki-icon.svg/240px-Anki-icon.svg.png" style="height:100px;max-width:100px;"><br>[Anki](https://marph91.github.io/jimmy/formats/anki/) |
31+
| **A** | <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Anki-icon.svg/240px-Anki-icon.svg.png" style="height:100px;max-width:100px;"><br>[Anki](https://marph91.github.io/jimmy/formats/anki/) | <img src="https://raw.githubusercontent.com/anyproto/anytype-ts/refs/heads/main/src/img/logo/symbol.svg" style="height:100px;max-width:100px;"><br>[Anytype](https://marph91.github.io/jimmy/formats/anytype/) |
3232
| **B** | <img src="https://bear.app/images/logo.png" style="height:100px;max-width:100px;"><br>[Bear](https://marph91.github.io/jimmy/formats/bear/) |
3333
| **C** | <img src="https://raw.githubusercontent.com/CacherApp/cacher-cli/e241f06867dba740131db5314ef7fe279135baf6/images/cacher-icon.png" style="height:100px;max-width:100px;"><br>[Cacher](https://marph91.github.io/jimmy/formats/cacher/) | <img src="https://raw.githubusercontent.com/giuspen/cherrytree/c822b16681b002b8882645d8d1e8f109514ddb58/icons/cherrytree.svg" style="height:100px;max-width:100px;"><br>[CherryTree](https://marph91.github.io/jimmy/formats/cherrytree/) | <img src="https://avatars.githubusercontent.com/u/53916365?s=200&v=4" style="height:100px;max-width:100px;"><br>[Clipto](https://marph91.github.io/jimmy/formats/clipto/) | <img src="https://www.colornote.com/wp-content/uploads/2016/05/cropped-favicon.png" style="height:100px;max-width:100px;"><br>[ColorNote](https://marph91.github.io/jimmy/formats/colornote/) |
3434
| **D** | <img src="https://seeklogo.com/images/D/day-one-logo-F4CA245C26-seeklogo.com.png" style="height:100px;max-width:100px;"><br>[Day&nbsp;One](https://marph91.github.io/jimmy/formats/day_one/) | <img src="https://images.saasworthy.com/dynalist_5288_logo_1576239391_xhkcg.jpg" style="height:100px;max-width:100px;"><br>[Dynalist](https://marph91.github.io/jimmy/formats/dynalist/) |

requirements/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
anyblock_exporter @ git+https://github.com/marph91/AnyBlock-To-Markdown.git@minimal-module-setup
12
beautifulsoup4==4.12.3
23
cryptography==43.0.3
34
enlighten==1.12.4

src/converter.py

+2
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,5 @@ def convert_file_or_folder(self, file_or_folder: Path, parent: imf.Notebook):
212212

213213
def convert(self, file_or_folder: Path):
214214
self.convert_file_or_folder(file_or_folder, self.root_notebook)
215+
# Don't export empty notebooks
216+
self.remove_empty_notebooks()

src/formats/anytype.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Convert AnyType notes to the intermediate format."""
2+
3+
import os
4+
from pathlib import Path
5+
6+
os.environ["TQDM_DISABLE"] = "1" # disable tqdm progress bars in anytype
7+
8+
from anyblock_exporter import AnytypeConverter # pylint: disable=import-error,wrong-import-position
9+
import common # pylint: disable=wrong-import-position
10+
import converter # pylint: disable=wrong-import-position
11+
12+
13+
class Converter(converter.BaseConverter):
14+
accepted_extensions = [".zip"]
15+
accept_folder = True
16+
17+
def convert(self, file_or_folder: Path):
18+
# TODO: fix duplicated nested output folder
19+
intermediate_markdown_folder = common.get_temp_folder() / self.output_folder
20+
21+
anytype_converter = AnytypeConverter(
22+
file_or_folder, intermediate_markdown_folder
23+
)
24+
anytype_converter.process_all_files()
25+
26+
# read the markdown again to respect settings like a custom resource folder
27+
markdown_converter = converter.DefaultConverter(self._config)
28+
markdown_converter.root_notebook = self.root_notebook
29+
markdown_converter.convert(intermediate_markdown_folder)

src/jimmy.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
def setup_logging(log_to_file: bool, stdout_log_level: str):
2424
LOGGER.handlers.clear()
2525

26-
# setup the root logger, but don't propagate. We will log using our own
26+
# setup the root logger, but don't propagate. We will log use our own
2727
# log handler. See: https://stackoverflow.com/a/71365918/7410886
2828
logging.basicConfig(level=logging.DEBUG)
2929
LOGGER.propagate = False
@@ -47,7 +47,10 @@ def setup_logging(log_to_file: bool, stdout_log_level: str):
4747

4848
# handle other loggers
4949
# https://stackoverflow.com/a/53250066/7410886
50-
other_loggers = [logging.getLogger(log) for log in ("pypandoc", "python-markdown")]
50+
other_loggers = [
51+
logging.getLogger(log)
52+
for log in ("anyblock_exporter", "pypandoc", "python-markdown")
53+
]
5154
for log in other_loggers:
5255
log.propagate = False
5356
log.handlers.clear()

test/data

Submodule data updated 169 files

test/test_convert.py

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def compare_dirs(dir1: Path, dir2: Path):
8282
[["anki/test_1/MEILLEUR_DECK_ANGLAIS_3000.apkg"]],
8383
[["anki/test_2/Ukrainian_Prepositions_pictsaudio_ENG-UA__UA-ENG.apkg"]],
8484
[["anki/test_3/Hebrew_Alphabet_with_vowels.apkg"]],
85+
[["anytype/test_1/Anytype.20241112.175339.64"]],
8586
[["bear/test_1/backup.bear2bk"]],
8687
[["bear/test_2/backup-2.bear2bk"]],
8788
[["cacher/test_1/cacher-export-202406182304.json"]],

0 commit comments

Comments
 (0)