diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-10-28 20:15:37 -0300 | 
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-10-28 20:15:37 -0300 | 
| commit | 985582b80c83dc894c383b41455973a1f9e7b562 (patch) | |
| tree | c7f2df1d68e7e7695e715ba0b41579edb0297e2a /scripts/acme/Wikitag | |
| parent | 2031bd979dc9c27b303e0a53bc0cc9f4f0ef715a (diff) | |
Diffstat (limited to 'scripts/acme/Wikitag')
| -rwxr-xr-x | scripts/acme/Wikitag | 36 | 
1 files changed, 36 insertions, 0 deletions
| diff --git a/scripts/acme/Wikitag b/scripts/acme/Wikitag new file mode 100755 index 0000000..645bf1a --- /dev/null +++ b/scripts/acme/Wikitag @@ -0,0 +1,36 @@ +#!/bin/zsh + +while getopts ":l" opt; do; case $opt in + l) label=1 ;; + *) exit 1 +esac; done + +cycle=( artist track album group ) + +src=$(</dev/stdin) + +if [[ ! $src =~ '^\[\[.*\]\]$' ]]; then + printf '[[%s]]' "$src"; exit 0 +fi + +src=$src:s/[[//:s/]]// + +if [[ ! $src =~ '^[^ ]+:' ]]; then + if [[ -v label ]]; + then printf '[[%s:%s|%s]]' ${cycle[1]} $(wikebab <<< "$src") "$src" + else printf '[[%s:%s]]' ${cycle[1]} $(wikebab <<< "$src") + fi; exit 0 +fi + +replacer=${src%:*} +value=${src#*:} + +place=${cycle[(ie)$replacer]} +length=${#cycle} +if (( place >= length )); then + next=1 +else + (( next = place + 1 )) +fi + +printf '[[%s:%s]]' ${cycle[$next]} $value \ No newline at end of file | 
