-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml2tex.py
More file actions
39 lines (30 loc) · 870 Bytes
/
xml2tex.py
File metadata and controls
39 lines (30 loc) · 870 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import getopt,sys
from register import parser,texwriter
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'f:o:')
except getopt.GetoptError as err:
print(str(err))
sys.exit(2)
filename = args[0]
outputName = args[0].split('.')[0]+'.tex'
for o,a in opts:
if o == '-f':
continue
elif o == '-o':
outputName = a
else:
assert False, "unhandled option"
blocks = parser.parser([filename])
writer = texwriter.TexWriter(blocks)
writer.build()
print("Writing into : %s"%outputName)
writer.save(outputName)
if __name__ == "__main__":
main()