git.iko.soy/typeable/pandoc
on master help sign in
pandoc.py: Fixed bug for {}, removed rawInline, rawBlock.
commit2a6e6324a6db7151a4bb103227893af47d61f84d authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 14 Aug 2013, 23:24 (13 years ago) parentf5426b4
1 file changed+12−19
scripts/pandoc.py+12−19
scripts/pandoc.py+12−19
@@ -18,15 +18,18 @@ def walk(x, action, format = ""):
1818 array = []
1919 for item in x:
2020 if isinstance(item, dict):
21− for k in item:
22− res = action(k, item[k], format)
23− if res is None:
24− array.append(walk(item, action, format))
25− elif isinstance(res, list):
26− for z in res:
27− array.append(walk(z, action, format))
28− else:
29− array.append(walk(res, action, format))
21+ if item == {}:
22+ array.append(walk(item, action, format))
23+ else:
24+ for k in item:
25+ res = action(k, item[k], format)
26+ if res is None:
27+ array.append(walk(item, action, format))
28+ elif isinstance(res, list):
29+ for z in res:
30+ array.append(walk(z, action, format))
31+ else:
32+ array.append(walk(res, action, format))
3033 else:
3134 array.append(walk(item, action, format))
3235 return array
@@ -61,16 +64,6 @@ def toJSONFilter(action):
6164 altered = walk(doc, action, format)
6265 json.dump(altered, sys.stdout)
6366
64−def rawInline(format, s):
65− """Returns a 'RawInline' inline object.
66− """
67− return {"RawInline": [{"unFormat": format}, s]}
68−
69−def rawBlock(format, s):
70− """Returns a 'RawBlock' inline object.
71− """
72− return {"RawBlock": [{"unFormat": format}, s]}
73−
7467def attributes(attrs):
7568 """Returns an attribute list, constructed from the
7669 dictionary attrs.