-
Notifications
You must be signed in to change notification settings - Fork 41
/
preprocess.py
26 lines (23 loc) · 975 Bytes
/
preprocess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
from Filist import Filist
def main(name, filename, *argv):
# print the contents of the given file
ft = Filist(filename)
ft.move_indexterms()
ft.sub_lines(r'section\*', r'section')
ft.sub_lines(r'\\begin{code}', r'\\begin{verbatim}plasTeXjava')
ft.sub_lines(r'\\end{code}', r'\\end{verbatim}')
ft.sub_lines(r'\\begin{trinket}.*', r'\\begin{verbatim}plasTeXjava')
ft.sub_lines(r'\\end{trinket}', r'\\end{verbatim}')
ft.sub_lines(r'\\begin{stdout}', r'\\begin{verbatim}')
ft.sub_lines(r'\\end{stdout}', r'\\end{verbatim}')
ft.sub_lines(r'Chapter~\\ref', r'~\\ref')
ft.sub_lines(r'Section~\\ref', r'~\\ref')
ft.sub_lines(r'page~\\pageref', r'~\\ref')
ft.sub_lines(r'Figure~\\ref', r'~\\ref')
ft.sub_lines(r'Exercise~\\ref', r'~\\ref')
#ft.sub_lines(r'\\java{\\%', r'\\java{%')
ft.sub_lines(r'\\textless\\textgreater\\', r'plasTeXangle')
print ft
if __name__ == '__main__':
main(*sys.argv)