Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_resources - hardcoded path, wikilinks, Obsidian #242

Closed
luckman212 opened this issue Apr 16, 2021 · 5 comments
Closed

_resources - hardcoded path, wikilinks, Obsidian #242

luckman212 opened this issue Apr 16, 2021 · 5 comments

Comments

@luckman212
Copy link

@luckman212 luckman212 commented Apr 16, 2021

hey @akosbalasko 👋

I'm using Yarle to bring content from Evernote into Obsidian.

Since Obsidian uses wikilinks formatting for attachments: ![[attachment-name]] and does not require a path prefix, I am wondering a few things:

  1. It seems that _resources is a hardcoded path prefix for attachments. Any way to move this to a config option?
  2. An option to output the links in minimized format ![[filename.2.png]] instead of ![[./_resources/filename.2.png]] would save a lot of hand-editing afterward
  3. I usually end up with a folder full of "unknown_filename.1.png", "unknown_filename.2.png" etc. These always have to be renamed and again hand-edited in the md file. Instead of using "unknown_filename-*" could it instead just generate a md5 hash and use that as its reference? This would eliminate the need for renaming/editing and also avoid collisions.

If you don't have time for this I can certainly take a crack at it but I should warn you, I've been working with TypeScript for about 5 hours 😱

@luckman212
Copy link
Author

@luckman212 luckman212 commented Apr 16, 2021

For now, I did the poor man's solution... a bash script that post-processes the output:

setup

  • save script below as yarle-postprocess.sh somewhere in your $PATH and chmod +x it
  • this assumes your Obsidian attachment dir is named attach

usage e.g.

cd /path/to/outputDir/converted/notes/Note Export/
yarle-postprocess.sh "<filename.md>"

script

#!/usr/bin/env bash

if [ ! -e "$1" ]; then
  echo "$1 not found"
  exit 1
fi

shopt -u nullglob

mkdir -p './attach'
for f in ./_resources/unknown_filename*; do
  echo "processing $f"
  hash=$(md5 -q "$f")
  sed -i.bak "s#\!\[\[$f#\!\[\[${hash}.png#g" "$1"
  cp -f "$f" "./attach/${hash}.png"
done

shopt -s nullglob

@akosbalasko
Copy link
Owner

@akosbalasko akosbalasko commented Apr 16, 2021

Hi @luckman212 , good to see you here!

Huh you've got many feat. requests, great! It looks I'll have time to implement them today.
the _resources folder can be configurable definitely, by default it can be empty which would result the same ![[filename.png]] I would use ObsidianMD value for outputFormat config for this, I mean if there is no resourceFolder configured and the outputFormat is ObsidianMD then the result would be ![[f.png]]. What do you think?
About your last question: what would be the benefit of replacing filenames by hashes? i mean in this case at least we have a human-readable filenames, not with hashes, we lost.

@luckman212
Copy link
Author

@luckman212 luckman212 commented Apr 16, 2021

@akosbalasko thanks for the reply. Yes I agree with making resourceFolder configurable and if (resourceFolder === null && outputFormat === 'ObsidianMD') then format should be ![[file.png]]

As for hash values as filenames. I am suggesting that ONLY if the resulting filename would have been "untitled.x.png" since that is non-descript and also results in many collisions since every note export would share the same filename. So using the hash would avoid this. See https://github.com/derwish-pro/obsidian-unique-attachments for more about that...

@akosbalasko
Copy link
Owner

@akosbalasko akosbalasko commented Apr 16, 2021

@luckman212 , okok, I get it.
Sorry, I'll be able to implement the requested things during the next week, some more important stuff came in.

@akosbalasko
Copy link
Owner

@akosbalasko akosbalasko commented Apr 25, 2021

Hi @luckman212 ,

I created separate stories for your feature requests:
Resource folder: #263
hash as filenames: #264

So let me close this one, I'll update them according to the progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants