# shellcheck shell=dash

xrc:mod:lib     html   clean    testdata    fparse

___x_cmd_html___main(){
    [ "$#" -gt 0 ] ||   set -- fmt

    local op="$1";      shift
    case "$op" in
        -h|--help)      ___x_cmd help -m html "$@";    return 0 ;;

        fmt|clean|tojson|toyml|tomd|frommd|trafi|plwr|links|rdbl|testdata|fparse)
                        ___x_cmd_html_"$op"     "$@"  ;;

        *)              N=html M="Unknown op -> $op" log:ret:64 ;;
    esac
}

___x_cmd_html_fmt(){
    ___x_cmd xq --html "$@"
}

___x_cmd_html_tojson(){
    ___x_cmd xq --json "$@"
}

___x_cmd_html_toyml(){
    ___x_cmd_html_tojson "$@" | ___x_cmd j2y
}

___x_cmd_html_trafi(){
    ___x_cmd trafi --xml --links --recall "$@"
}

___x_cmd_html_rdbl(){
    ___x_cmd readability "$@"
}

___x_cmd_html_plwr(){
    ___x_cmd plwr htmlsource    "$@"
}

___x_cmd_html_links(){
    ___x_cmd links source       "$@"
}

___x_cmd_html_tomd(){
    ___x_cmd pandoc -f html -t markdown
}

___x_cmd_html_frommd(){
    ___x_cmd pandoc -f markdown -t html # -s lib/nihao/nihao.en.md
}
