# DOM to LaTeX resources/toolkits? [closed]

I want to convert some webpages to nicely formatted Latex documents. The webpage is a discussion forum, with deeply nested comments. Before I begin to write my own naive implementation, are there any tools/scripts which help with such html->latex structure transformation. For example, suppose a thread hierarchy is a simple ul li nesting , I need a tool that helps me put it into itemize blocks. And if possible, even for more complex div and span nesting.

Here is an example to make it more explicit:

<ul>
<li>I am a parent comment of the root post. This is my opinion.</li>
<ul>
<li> I disagree with the parent and these are my opinions.</li>
<ul>
<li> Your opinion is wrong because of such and such facts. </li>
<ul>
<li> I am a deeply nested comment </li>
</ul>
<li> I agree, I also disagree with parent comment. </li>
</ul>
<li> I am another parent comment to the root post </li>
<ul>

To convert this to

\begin{itemize}
\item I am a parent comment of the root post. This is my opinion.
\begin{itemize}
\item I disagree with the parent and these are my opinions.
\begin{itemize}
\item Your opinion is wrong because of such and such facts.
\begin{itemize}
\item I am a deeply nested comment.
\end{itemize}
\item  I agree, I also disagree with parent comment.
\end{itemize}
\end{itemize}
\item I am another parent comment to the root post
\end{itemize}

-
One way is to parse the webpage to some internal representation, and convert that to LaTeX. Examples of that kind of tools include Pandoc (Haskell) and Kramdown (Ruby). –  morbusg Jul 5 '12 at 4:03
@morbusg do you know of alternatives for python/C/C++ ? Kramdown looks good. –  yayu Jul 5 '12 at 4:07
ConTeXt can directly parse and typeset XML (and, by extension, XHTML). See for example dl.contextgarden.net/myway/tas –  Aditya Jul 5 '12 at 7:04
@yayu: sorry, I don't remember seeing one. –  morbusg Jul 5 '12 at 15:25