我正在嘗試將自定義HTML轉換爲使用Wordpress帖子作爲源的LaTeX轉換器。使用PHP將HTML轉換爲另一種語法(LaTeX)
基本上,它需要做一些 「取代」,如:
<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),但我無法獲得成功的結果。
謝謝。
你看看:http://html2latex.sourceforge.net/ – RobertPitt 2011-02-06 19:52:45