forked from Siyavula/siyavula.latex2image
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
23 lines (16 loc) · 714 Bytes
/
example.py
File metadata and controls
23 lines (16 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import hashlib
from siyavula.latex2image.imageutils import run_latex
def read_equations():
txt = open('test-equations-short.txt', 'r').read()
equations = [e for e in txt.split('----') if len(e.strip()) > 0][0:50]
for i, e in enumerate(equations):
if 'aligned' in e:
equations[i] = e.strip()[2:-2].replace('aligned', 'align')
return equations
if __name__ == "__main__":
equations = read_equations()
for i, equation in enumerate(equations):
codehash = hashlib.md5(equation).hexdigest()
cache_path = 'cache'
imagepath = run_latex('equation', codehash, equation, cache_path)
print '\n {}/{} > '.format(i+1, len(equations)) + imagepath