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

Resolving relative images in subdirectories #31

Open
Voronenko opened this issue Oct 21, 2020 · 4 comments
Open

Resolving relative images in subdirectories #31

Voronenko opened this issue Oct 21, 2020 · 4 comments

Comments

@Voronenko
Copy link

Voronenko commented Oct 21, 2020

For markdown documents in subdirectories referring relative images,like

![alt](diagrams/context/context.svg)

tool is able to find image only in scenario, when it is executed from the same directory where file resides.

If I will try to execute it passing file path, like

mark -u $CF_USER -p $CF_TOKEN -b $CF_DOMAIN -f docs/subdirectory/$file

it will fail.

So far workaround is manual traversing of dirs one by one, but would be nice if relative references could be resolved.

declare -a dirs=("docs", "docs/subfolder1", "docs/subfolder2" )

for d in ${dirs[@]}; do

(
cd $d
for file in $(find -maxdepth 1 -type f -name '*.md'); do
  echo "> Sync $file";
#  echo mark -u $CF_USER -p $CF_TOKEN -b $CF_DOMAIN -f $file
  mark -u $CF_USER -p $CF_TOKEN -b $CF_DOMAIN -f $file || exit 1;
  echo;
done
)

done
@lukiffer
Copy link
Contributor

The workaround listed does work. I've modified it a bit to make it a little more flexible until I've got time to look for a fix in go:

set -e
while read -r -d '' file; do
  echo "Syncing $file..."
  pushd "$(dirname "$file")" > /dev/null
    filename="$(basename "$file")"
    mark -k -f "$filename"
  popd > /dev/null
done < <(find . -type f -name "*.md" -print0)

@GrantAdkins
Copy link

The workaround listed does work. I've modified it a bit to make it a little more flexible until I've got time to look for a fix in go:

set -e
while read -r -d '' file; do
  echo "Syncing $file..."
  pushd "$(dirname "$file")" > /dev/null
    filename="$(basename "$file")"
    mark -k -f "$filename"
  popd > /dev/null
done < <(find . -type f -name "*.md" -print0)

Unfortunately this workaround fails when using it in a Bitbucket pipeline yaml file, resulting error is "syntax error near unexpected token `do'"

Without this workaround, I can get the files attached in Confluence by specifying the full path in the meta tags but they're not embedded in the page itself as the path using in the markdown doesn't exactly match the full path.

@chipbite
Copy link

chipbite commented Dec 21, 2021

Would be really good to have this support in place, right now, having all image assets in the same folder quickly gets problematic for us.
(Misunderstood issue here, subfolders work ok)

@kovetskiy
Copy link
Owner

I'm open to merge any feature which will help the community 😺

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

No branches or pull requests

5 participants