Skip to content

Commit

Permalink
Use hard-coded / as path delimiter in markdown attachment path
Browse files Browse the repository at this point in the history
  • Loading branch information
keithfancher committed Feb 17, 2023
1 parent 519fed7 commit 4f54d82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ and this project adheres to the
it is expanded (non-recursively) into the list of the `.json` files in that
directory.

### Fixed

- Windows: embedded media attachments display correctly now. (Turns out
Obsidian wants `/` as a path delimiter even in Windows.)


## 0.2.0 - 2023-02-13

Expand Down
9 changes: 7 additions & 2 deletions src/Kept.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ updateNoteAttachments note = note {metadata = newMetadata}
-- Prepend the `media` directory to our attachment paths. Note this is the
-- final RELATIVE path that will be written to the markdown note.
newAttachmentPath :: [Attachment] -> [Attachment]
newAttachmentPath = map (mediaDirectory </>)
newAttachmentPath = map prependMediaDir
where
mediaDirectory = ".." </> attachmentDir
-- NOTE: Using a hard-coded path-delimiter here (`/`) rather than the
-- saner, cross-platform function (`</>`). This path, written to the
-- markdown note, needs to use `/` for embedded attachments to work, EVEN
-- in Windows. (At least in Obsidian.)
mediaDirectory = "../" <> attachmentDir
prependMediaDir dir = mediaDirectory <> "/" <> dir

printNoteFile :: KeptOptions -> Note -> IO ()
printNoteFile opts note = do
Expand Down

0 comments on commit 4f54d82

Please sign in to comment.