【发布时间】:2011-06-22 09:19:05
【问题描述】:
我正在尝试做一个自定义 HTML 到 LaTeX 转换器,它使用 Wordpress 帖子作为来源。
基本上,它需要做一些“替换”,比如:
<h2>H2 Title</h2>
<p>Text text text</p>
<img src="/image.png" alt="Image ALT tag" \>
到这里
\begin{document}
\section{H2 Title}
Text text text
\shorthandoff{=}
\begin{figure}[H]
\centering
\includegraphics[scale=0.7]{./img/image.png}
\caption{Image ALT tag}
\end{figure}
\shorthandon{=}
\end{document}
我应该使用哪种方法?是否有一个 HTML DOM 解析器 允许像这样的替换?或者其他建议?
更新:有什么方法可以正确在 PHP 的 HTML DOM 树中行走?我尝试了 RecursiveDOMIterator (http://stackoverflow.com/questions/4431142/loop-through-all-elements-of-body-tags-using-dom) 但我无法获得成功的结果。
谢谢。
【问题讨论】: