url="https://gitlab.com/saalen/highlight/-/archive/v3.58/highlight-v3.58.tar.gz"

tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT

(
    cd "$tmp_dir"
    base="$(basename "$url" ".tar.gz")"
    wget "$url"
    tar -xaf "$(basename "$url")" \
        "$base/filetypes.conf" \
        "$base/langDefs" \
        "$base/themes" \
        "$base/plugins"
    HIGHLIGHT_DATADIR="${HIGHLIGHT_DATADIR:-"$HOME/.highlight"}"
    mkdir -p "$HIGHLIGHT_DATADIR"
    mv "$base"/* "$HIGHLIGHT_DATADIR"
    rmdir "$base"
)