Skip to content

Commit

Permalink
Add support of wiki links with section, like [[filename#section]] (#71)
Browse files Browse the repository at this point in the history
In Obsidian the [[filename#section]] form is supported, so add it here,
too. Removing the section part is the best in `obsidian-wiki->normal`
as this is the place where the `.md` extension is added to the link.

Fixes Issue #70.
  • Loading branch information
LA-Toth authored Nov 5, 2023
1 parent cd483a2 commit 452b830
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion obsidian.el
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,12 @@ link name must be available via `match-string'."
"Add extension to wiki link F if none."
(if (file-name-extension f)
f
(s-concat f ".md")))
(s-concat (obsidian--remove-section f) ".md")))

(defsubst obsidian--remove-section (s)
"Remove section from file path.
From 'filename#section' keep only the 'filename'."
(replace-regexp-in-string "#.*$" "" s))

(defun obsidian-follow-wiki-link-at-point (&optional arg)
"Find Wiki Link at point. Opens wiki links in other window if ARG is non-nil."
Expand Down

0 comments on commit 452b830

Please sign in to comment.