mirror of
https://github.com/LouisShark/chatgpt_system_prompt.git
synced 2025-07-05 14:20:33 -04:00
fix: toc bash's error
This commit is contained in:
parent
8c4f2c8408
commit
bb3423b6dc
2 changed files with 37 additions and 36 deletions
|
@ -15,12 +15,13 @@ generate_toc() {
|
|||
local safe_title=$(echo "$title" | sed 's/[<>::"\/\\|?*]/_/g')
|
||||
# Rename the source file with the safe_title
|
||||
mv "$file" "$dir/$safe_title.md"
|
||||
# shellcheck disable=SC2001
|
||||
local link=$(echo "$dir/$safe_title.md" | sed "s|^$base_dir/||")
|
||||
local encoded_link=$(python -c "import urllib.parse; print(urllib.parse.quote('''$link'''))")
|
||||
# Create a relative link
|
||||
local relative_link="${dir#$base_dir/}/$safe_title.md"
|
||||
# Manually encode only spaces and other few characters if needed
|
||||
local encoded_link=$(echo "$relative_link" | sed 's/ /%20/g; s/"//g')
|
||||
echo " - [$safe_title]($encoded_link)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
generate_toc .
|
||||
generate_toc .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue