5 from pandocfilters
import (toJSONFilter
, RawInline
, Space
, Str
, walk
, Image
,
9 Pandoc filter for Markdown that converts most endnotes into
10 Pandoc's inline notes. If input notes had multiple paragraphs,
11 the paragraphs are joined by a space. But if an input note
12 had any blocks other than paragraphs, the note is left as is.
15 #inkscape -z sv/bridge_phy.svg --export-png=bridge.png
16 out
= open("/tmp/log.txt", "w")
18 def query(k
, v
, f
, meta
):
22 elif isinstance(v
, list):
23 if inlines
and k
== 'Para':
24 inlines
.append(Space())
28 def inlinenotes(k
, v
, f
, meta
):
29 out
.write("k v f meta %s %s %s %s\n" % \
30 (repr(k
), repr(v
), repr(f
), repr(meta
)))
33 if k
== u
'Image' and f
== 'latex':
35 out
.write(" image %s\n" % (imgname
))
36 # HACK! works only relative to openpower directory!
37 if imgname
.startswith("/"):
38 imgname
= ".." + imgname
39 png
= imgname
.replace(".svg", ".png")
40 png
= os
.path
.split(png
)[1]
41 png
= "tex_out/%s" % png
42 subprocess
.run(["inkscape", "-z", "-C", imgname
,
43 "--export-png=%s" % png
],
44 stdout
=subprocess
.PIPE
)
47 if k
== 'Str' and f
== 'latex':
49 if v
.startswith("[[") and v
.endswith("]]"):
52 link
, ref
= link
.split("|")
53 return Link(['', [], []],
56 out
.write(" link %s\n" % link
)
57 lookups
= {'sv/overview': 'Overview Chapter',
58 'sv/svp64': 'SVP64 Chapter',
59 'svp64/appendix': 'SVP64 Appendix',
62 out
.write(" found %s\n" % lookups
[link
])
63 return Link(['', [], []],
67 out
.write(" link type %s\n" % \
71 if __name__
== "__main__":
72 toJSONFilter(inlinenotes
)