-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfigure.py
More file actions
31 lines (25 loc) · 749 Bytes
/
figure.py
File metadata and controls
31 lines (25 loc) · 749 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
#!/usr/bin/env python
# debugging
from __future__ import print_function
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
from pandocfilters import toJSONFilter, RawInline
from pfcompat import Image
def latex(x):
return RawInline('latex', x)
def figure(key, value, format, meta):
#eprint("Key: " + key)
if key == 'Image':
caption = value[1]
image = Image(value[0], value[1], value[2])
return \
[ latex(r'\begin{figure}' + '\n') \
, image, latex('\n') \
, latex(r'\caption{') \
] + caption + \
[ latex('}' + '\n') \
, latex(r'\end{figure}') \
]
if __name__ == "__main__":
toJSONFilter(figure)