Clipboard to Html to md with formatting

I tried my best to convert rtf clipboard data to html but i get just plain text without formatting, as a result:

set fNex to "docx"
set tmpDir to POSIX path of ((path to desktop folder from user domain as text) & "Html:" as text)
do shell script "mkdir -p '" & POSIX path of tmpDir & "'"

set cmd to "pbpaste -Prefer rtf | textutil -stdin -convert html -output '" & (tmpDir & "Test.html" as text) & "'"
do shell script cmd

of course, i could generate a html file from a rtf, that solution works nicely.
Finally my goal is to convert html to markdown -with nice formatting attributes.

But if i use Pandoc - a universal document converter, all formatting gets lost, converting from html to md. The manual of pandoc is very long - and i tried just some basic commands right now.
The default settings of pandoc are totally insufficient - you get just plain text - in that case i do not need any conversion at all - textutil does it better and preserves formatting from rtf to html. Unluckily, textutil cannot deal with markdown and maybe won’t ever…

Hi. My understanding is that standard input is plain text, so textutil’s source would seemingly have to be a file, rather than stdin.

do shell script "textutil -convert html -input " & ((path to desktop folder as text) & "whatever.rtf")'s POSIX path's quoted form & " -output " & (path to desktop folder as text)'s POSIX path's quoted form