mark
mark copied to clipboard
Resolving relative images in subdirectories
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
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)
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.
~~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)
I'm open to merge any feature which will help the community 😺