mirror of
https://github.com/LouisShark/chatgpt_system_prompt.git
synced 2025-07-05 22:30:37 -04:00
fix: replace colon or other symbol(some systems don't support) in filename
This commit is contained in:
parent
b6e7e9e0f9
commit
3b2579197c
3 changed files with 8 additions and 5 deletions
|
@ -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 .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue