From: Matthew L. <lei...@ci...> - 2009-01-27 14:01:13
|
Hi, I've got a restructured text file lessons.txt with metadata on every class I want to teach in a course this term. I'd like to create some LaTeX files to use for class notes that have that metadata in them already. The actual math of the class has to be put in later, but I'm trying to automate some of what I do every day. I have another file hw.txt with homework assignments in it; I'd like to merge those into the class notes as well. There's some tedious data munging I want, too, like having the lesson files in a directory based on the lesson title, naming the files based on the lesson title (in a different way), etc. I'm trying to figure out the best way to do this. I use the rst2xxx.py tools a lot to produce latex or html files. One possible solution would be to convert lessons.txt and hw.txt to docutils XML and use XSLT to make the LaTeX files. But I'm not so excited about doing some of the directory-creating and text manipulation in XSLT. Another solution is to start with the docutils parser and select what I need from the document's internal data structure, much like selecting nodes from an XML tree in XSLT. This way I can use whatever python code I need to manipulate text or create/open files. But I don't know too much about this internal structure, and I couldn't find it documented. So I thought I'd throw it out to the list. How would you go about this task? Thanks for any advice, Matt -- Matthew Leingang Clinical Associate Professor of Mathematics lei...@ci... |