On 31/08/10 20:52, Hal Kierstead wrote:
I agree that this would be very pleasing, especially when working with
collaborators who do not use LyX and who use many new commands.
Hal
This is the simple python code which takes a filename as an argument, and
creates the file PlastexProcessed.tex
-----------------------------------------------------
#!/usr/bin/python
# _*_ coding: UTF-8 _*_
import sys
from plasTeX.TeX import TeX
doc = TeX(file=sys.argv[1]).parse()
# The processed document is contained in the string doc.source
# Print to file
f = open('PlastexProcessed.tex', 'w')
f.write(doc.source.encode("utf-8"))
f.close()
----------------------------------------------------
*********** Example: ************
It converts this:
--------------------------------------
\documentclass{article}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\begin{document}
\be
\int f(x) dx = 0
\ee
\end{document}
--------------------------------------
into this:
--------------------------------------
\documentclass{article}
\newcommand{\be }{\begin {equation}} \newcommand{\ee }{\end {equation}}
\begin{document} \begin{equation} \int f(x) dx = 0 \end{equation}
\end{document}
-------------------------------------
In the latter file, the \newcommands are not used in the text, so it is better
suited for LyX import. The \newcommands can be deleted manually. It tends to
make long lines, but that doesn't seem to matter for the subsequent LyX import.
Best regards
Torquil Sørensen