fix: replace colon or other symbol(some systems don't support) in filename
This commit is contained in:
@@ -11,11 +11,14 @@ generate_toc() {
|
||||
echo " $(generate_toc "$file")"
|
||||
elif [ -f "$file" ] && [[ $file == *.md ]]; then
|
||||
local title=$(basename "$file" .md)
|
||||
# Replace Windows incompatible characters with '_'
|
||||
local safe_title=$(echo "$title" | sed 's/[<>::"\/\\|?*]/_/g')
|
||||
# shellcheck disable=SC2001
|
||||
local link=$(echo "$file" | sed "s|^$base_dir/||")
|
||||
local encoded_link=$(python -c "import urllib.parse; print(urllib.parse.quote('''$link'''))")
|
||||
echo " - [$title]($encoded_link)"
|
||||
echo " - [$safe_title]($encoded_link)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
generate_toc .
|
||||
generate_toc .
|
||||
|
||||
Reference in New Issue
Block a user