Skip to content

fix: update %20-encoded markdown links when moving notes - #143

Open
jayhemnani9910 wants to merge 1 commit into
Yakitrak:mainfrom
jayhemnani9910:fix/move-encoded-markdown-links
Open

jayhemnani9910 wants to merge 1 commit into
Yakitrak:mainfrom
jayhemnani9910:fix/move-encoded-markdown-links

Conversation

@jayhemnani9910

Copy link
Copy Markdown

Description

move updates [text](folder/note.md) links since #58, but not the form Obsidian writes for a note whose name has a space: [text](folder/Two%20Words.md). Those links keep pointing at the old file, and move reports success.

# vault/links.md:  c [t1](folder/Two%20Words.md)
notesmd-cli move "folder/Two Words" "folder/Three Words"
# before: c [t1](folder/Two%20Words.md)    (dead link)
# after:  c [t1](folder/Three%20Words.md)

GenerateLinkReplacements now also adds the %20 forms of the .md markdown link patterns (plain and ./) when the old path has a space.

Motivation and Context

Obsidian encodes spaces as %20 in markdown links (its "Internal links" help shows [Three laws of motion](Three%20laws%20of%20motion.md)). With "Use [[Wikilinks]]" off, every move or rename of such a note from the CLI breaks the links to it.

Checklist:

  • I have written unit tests for my changes.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Added a "Note name with spaces" case to TestGenerateLinkReplacements; it fails without the change. go test ./... passes. Ran the steps above with a built binary on a scratch vault: both %20 links (plain and ./) are updated, the wikilink still is.

Obsidian writes markdown links to notes with spaces as [text](folder/My%20Note.md). move only matched the raw path, so those links kept pointing at the old file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant