Skip to content

Commit

Permalink
Fix broken wiki links in subdirectories (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu authored Apr 23, 2022
1 parent 0bfab74 commit c237b4d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.

* [#126](https://github.com/mickael-menu/zk/issues/126) Embedded image links shown as not found.
* [#152](https://github.com/mickael-menu/zk/issues/152) Incorrect timezone for natural dates.
* [#170](https://github.com/mickael-menu/zk/issues/170) Broken wiki links in subdirectories.


## 0.9.0
Expand Down
2 changes: 1 addition & 1 deletion internal/core/note_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (n *Notebook) ParseNoteWithContent(absPath string, content []byte) (*Note,
}

for _, link := range contentParts.Links {
if !strutil.IsURL(link.Href) {
if !strutil.IsURL(link.Href) && link.Type == LinkTypeMarkdown {
// Make the href relative to the notebook root.
href := filepath.Join(filepath.Dir(absPath), link.Href)
link.Href, err = n.RelPath(href)
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/blank-slug/.zk/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[note]
filename = "{{slug title}}"
22 changes: 22 additions & 0 deletions tests/issue-170.tesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Wiki links in subdirectories are broken
# https://github.com/mickael-menu/zk/issues/170

$ cd blank-slug

$ touch one.md
$ echo "[[one]]" > two.md
$ mkdir my_dir
$ echo "[[one]]" > my_dir/three.md

$ zk list -qfpath
>my_dir/three.md
>one.md
>two.md

$ zk list --link-to one.md -qfpath
>my_dir/three.md
>two.md

$ zk list --linked-by my_dir/three.md -qfpath
>one.md

0 comments on commit c237b4d

Please sign in to comment.