Is there some tool that would turn an HTML with mathjax into a valid LaTeX document? I undernstand that mathjax is already LaTeX, but if that is mixed with text, then simply saving the text representation of an HTML document is not going to work. E.g., the underscore should be turned into a backslash + _, when it is in the text section, while it should be left alone, if it is in a math environment. My question is, whether there is a way to do this automatically. I would prefer a javascript solution, but if that is absolutely not possible, I could live with a tool (e.g., python) that I can call from the command line.
Thanks,