mark icon indicating copy to clipboard operation
mark copied to clipboard

Resolving relative images in subdirectories

Open Voronenko opened this issue 3 years ago • 4 comments

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

Voronenko avatar Oct 21 '20 15:10 Voronenko

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)

lukiffer avatar Nov 17 '20 20:11 lukiffer

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.

GrantAdkins avatar Nov 30 '20 00:11 GrantAdkins

~~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)

chipbite avatar Dec 21 '21 14:12 chipbite

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

kovetskiy avatar Dec 21 '21 18:12 kovetskiy