12345678910111213141516171819202122232425262728 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import re, glob
- def get_definitions(filename):
- with open(filename) as f:
- content = f.read()
- pattern = re.compile(r"\\begin{definition}.*?\\end{definition}", re.DOTALL)
- m = re.findall(pattern, content)
- return "\n\n".join('\\vspace*{{\\fill}}\n{0}\n\\vspace*{{\\fill}}\\clearpage'.format(definition) for definition in m)
- #return "\n\n".join('\\begin{{flashcard}}{{a}}\n{0}\n\\end{{flashcard}}'.format(definition) for definition in m)
- def write_definitions_to_template(definitions, template="mathe-vorlage.tex", target="definitionen.tex"):
- with open(template) as f:
- content = f.read()
- content = content.replace('%CONTENT%', definitions)
- with open(target, 'w') as f:
- f.write(content)
- if __name__ == "__main__":
- definitions = []
- for texsource in sorted(glob.glob("../Kapitel*.tex")):
- definitions.append(get_definitions(texsource))
- write_definitions_to_template("\n\n\n".join(definitions))
|