diff --git a/plugin/obsidian.py b/plugin/obsidian.py index abef7c4..8bb8e40 100644 --- a/plugin/obsidian.py +++ b/plugin/obsidian.py @@ -1,6 +1,7 @@ import os import json from pathlib import Path +import urllib.parse import webbrowser import logging @@ -44,8 +45,9 @@ def get_note(vault_id, note_path): def open_note(vault_name, note_path): - URI = f'open?vault={vault_name}&file={note_path}'.replace(' ', '%20').replace('/', '%2F').replace('\\', '%2F') - URI = f'obsidian://{URI}' + vault_name = urllib.parse.quote(vault_name) + note_path = urllib.parse.quote(note_path) + URI = f'obsidian://open?vault={vault_name}&file={note_path}' webbrowser.open(URI) class Vault(object): @@ -134,4 +136,4 @@ def checklists(self): for note in vault.notes(): print(note.title) open_note(vault.name, str(note.relative_path)) - break \ No newline at end of file + break