# shellcheck shell=dash

___x_cmd_web_tomd___main(){
    [ "$#" -gt 0 ] ||       set -- --help

    local op="$1"
    case "$op" in
        -h|--help)      ___x_cmd help -m web tomd "$@" ; return 0 ;;
        *)              ___x_cmd_web_tomd___convert "$@" ;;
    esac
}

___x_cmd_web_tomd___convert(){
    local url="$1"
    [ -n "$url" ]   ||  N=web M="Please provide url." log:ret:64

    # First try to fetch the content
    local content
    content="$(___x_cmd_web_fetch___main "$url")" || return $?

    # Then convert to markdown
    printf '%s\n' "$content" | ___x_cmd trafi tomd
}
