Skip to content

Commit a6906cb

Browse files
committed
fix path for obsidian markdown import
1 parent a50f913 commit a6906cb

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,27 @@ res = ea.upload_md_folder(
277277
)
278278
```
279279

280+
### Import from Obsidian
281+
282+
Obsidian has a very unique linking system for files. You should use [obsidian-export
283+
](https://github.com/zoni/obsidian-export) to convert a Obsidian vault to regular Markdown files. Then you should be
284+
able to import the note into Trilium with trilium-py.
285+
286+
Convert it first.
287+
288+
```
289+
obsidian-export /path/to/your/vault /out
290+
```
291+
292+
Then import just like a normal markdown, trilium-py will handle the images for you.
293+
294+
```
295+
res = ea.upload_md_folder(
296+
parentNoteId="root",
297+
mdFolder="E:/data/out",
298+
)
299+
```
300+
280301
### Import from other markdown software
281302

282303
In general, markdown files have variety of standards. You can always try import them with

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# For a discussion on single-sourcing the version across setup.py and the
4444
# project code, see
4545
# https://packaging.python.org/guides/single-sourcing-package-version/
46-
version='0.7.0', # Required
46+
version='0.7.1', # Required
4747

4848
# This is a one-line description or tagline of what your project does. This
4949
# corresponds to the "Summary" metadata field:

src/trilium_py/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,8 @@ def upload_md_file(self, file: str, parentNoteId: str):
665665
)
666666
# print(res)
667667
image_note_id = res['note']['noteId']
668-
image_url = f"api/images/{image_note_id}/{res['note']['title']}"
668+
# fix path with `/` in it, the param should be quoted. e.g. relative url from obsidian
669+
image_url = f"api/images/{image_note_id}/{urllib.parse.quote(res['note']['title'], safe='')}"
669670
print(image_url)
670671

671672
html = html.replace(image_path, image_url)

0 commit comments

Comments
 (0)