diff options
| author | Marc Vertes <mvertes@free.fr> | 2021-06-19 13:00:21 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2021-06-19 13:00:21 +0200 |
| commit | 53569210e7967c6d891affb027c1ea202194f9c0 (patch) | |
| tree | 9a7aac0f9df86f211f7076b0e56256c334b8ab5e /bin/vimki | |
| parent | 2621ec5405f52343cf253d02e307c5b160cf7f04 (diff) | |
vimki: rename handle accents and punctuation
Diffstat (limited to 'bin/vimki')
| -rwxr-xr-x | bin/vimki | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -5,25 +5,46 @@ # rename changes the link name and propagates the change in the wiki rename1() { gawk -v old="$1" -v new="$2" -v IGNORECASE=1 ' + BEGIN { + rx = old + gsub(/_/, "\\W+", rx) + gsub(/a/, "[aåäáàâã]", rx) + gsub(/c/, "[cç]", rx) + gsub(/e/, "[eéèêë]", rx) + gsub(/i/, "[iîíìï]", rx) + gsub(/o/, "[oôöóõò]", rx) + gsub(/u/, "[uùûüú]", rx) + gsub(/y/, "[yÿ]", rx) + gsub(/n/, "[nñ]", rx) + } { - gsub("[[]" old "[]]", "[" new "]") + gsub("[[]" rx "[]]", "[" new "]") print } ' "$3" } linkfile() { - echo "$1" - #echo "$1" | tr '[:upper:] àçéèêëîïôèùûü' '[:lower:]_aceeeeiiouuu' + echo "$1" | + tr '[:upper:]' '[:lower:]' | + tr 'åäáàâãçéèêëîíìïôöóõòùûüúÿñ' 'aaaaaaceeeeiiiiooooouuuuyn' | + awk '{gsub(/\W+/, "_"); print}' } rename() { - for f in *; do + for f in *.md; do + [ "$(head -c 8 "$f")" = VimCrypt ] && continue rename1 "$1" "$2" "$f" > "$f.$$" && mv "$f.$$" "$f" done oldf="$(linkfile "$1")" [ -f "$oldf" ] && mv "$oldf" "$(linkfile "$2")" } +fixfiles() { + for f in *; do + mv "$f" "$(linkfile "$f")" + done +} + cd ~/Wiki "$@" |
