Is there javascript to convert HTML to markdown?
Theoretically, you can convert it back. You'd have to write your own DOM traversal code and convert the HTML back to Markdown.
Generally Markdown is thought to be the human readable/writable source of the information that is converted to HTML for further markup and styling.
HTML can be much more complex than Markdown and can be indefinitely nested and partitioned into tags. This is why it's so questionable to write a general purpose converter which reliably converts HTML back to Markdown. Just imagine all the whitespace and paragraphs going bye-bye and possibly causing a terrible mess for the human eye.
My suggestion is: Unless you generate originating HTML yourself and know what it consists of, don't convert it back to Markdown. Keep the Markdown version all the time and convert to HTML when needed.
I have also collaborated on a project on github that does this. At this moment, it is only tested in browser.
html2markdown
I have done a lot of testing on web. Added ton of unit tests. Still not perfect but works nicely. Feedback welcome and I will be happy to receive pull requests or fix any defects you find.
I've started a project to do this:
https://github.com/domchristie/turndown
It's still in its early stages, so has not been heavily tested, but it's a start.
Feedback/contributions welcome.