"Paul McGuire" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Parsing TeX is definitely not for the faint-of-heart!  You might try
> something like QuotedString('$', escQuote='$$') in pyparsing.  (I've
> not poked at TeX or its ilk since the mid-80's so my TeXpertise is
> long rusted away.)
>
> I know of two projects that have taken on the problem using pyparsing
> - one is the mathtext module in John Hunter's matplotlib, and Tim
> Arnold posted some questions on the subject a while back - try
> googling for "pyparsing tex" for further leads.
>
> -- Paul

Definitely agree that TeX can get pretty complicated. My method (writing a 
converter from one TeX tag system to another)  was to pre-parse using string 
match/replace for really simple stuff, regular expressions for the more 
complex and pyparsing for the really tough stuff.

One thing that was surprisingly hard for me to figure out was filtering out 
comments. I finally just looped through the file line by line, looking for a 
'%' that wasn't in a verbatim environment and wasn't escaped, etc.
Funny how sometimes the simplest thing can be difficult to handle.

Definitely pyparsing made the job possible; I can't imagine that job without 
it.

--Tim Arnold



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to