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 not v
.startswith("[["):
51 find_brack
= v
.find(']]')
54 link
= v
[2:find_brack
]
55 out
.write(" link %s\n" % link
)
56 lookups
= {'sv': 'Scalable Vectors for Power ISA',
57 'SV|sv': 'Scalable Vectors for Power ISA',
58 'openpower/sv': 'Scalable Vectors for Power ISA',
59 'sv/overview': 'Overview Chapter',
60 'sv/vector_isa_comparison': 'Vector ISA Comparison',
61 'sv/comparison_table': 'ISA Comparison Table',
62 'sv/compliancy_levels': 'Compliancy Levels',
63 'sv/svp64': 'SVP64 Chapter',
64 'svp64': 'SVP64 Chapter',
66 'sv/normal': 'Arithmetic Mode',
67 'sv/ldst': 'Load/Store Mode',
68 'sv/cr_ops': 'Condition Register Fields Mode',
69 'sv/executive_summary': 'Exevutive Summary',
70 'sv/branches': 'Branch Mode',
71 'sv/setvl': 'setvl instruction',
72 'sv/svstep': 'svstep instruction',
73 'sv/remap': 'REMAP subsystem',
74 'sv/remap/appendix': 'REMAP Appendix',
75 'sv/mv.swizzle': 'Swizzle Move',
76 'sv/mv.vec': 'Pack / Unpack',
77 'svp64/appendix': 'SVP64 Appendix',
78 'sv/svp64/appendix': 'SVP64 Appendix',
79 'sv/svp64_quirks': 'SVP64 Quirks',
80 'openpower/isa/simplev': 'Simple-V pseudocode',
81 'opcode_regs_deduped': 'SVP64 Augmentation Table',
82 'sv/av_opcodes' : 'Audio and Video Opcodes',
83 'av_opcodes' : 'Audio and Video Opcodes',
84 'sv/vector_ops' : 'SV Vector ops',
85 'sv/int_fp_mv' : 'FP/Int Conversion ops',
86 'sv/bitmanip' : 'Bitmanip ops',
87 'sv/cr_int_predication' : 'CR Weird ops',
88 'cr_int_predication' : 'CR Weird ops',
89 'sv/fclass' : 'FP Class ops',
90 'sv/biginteger' : 'Big Integer',
91 'sv/biginteger/analysis' : 'Big Integer Analysis',
92 'isa/svfparith' : 'Floating Point pseudocode',
93 'isa/svfixedarith' : 'Fixed Point pseudocode',
94 'openpower/isa/branch' : 'Branch pseudocode',
95 'openpower/transcendentals' : 'Transcendentals',
98 out
.write(" found %s\n" % lookups
[link
])
99 return [Link(['', [], []],
100 [Str("{"+lookups
[link
]+"}")],
101 ['#%s' % link
, '']), Str(v
[find_brack
+2:])]
103 link
, ref
= link
.split("|")
104 return [Link(['', [], []],
106 [ref
, '']), Str(v
[find_brack
+2:])]
108 out
.write(" link type %s\n" % \
112 if __name__
== "__main__":
113 toJSONFilter(inlinenotes
)