4Pandoc filter to process code blocks with class "abc" containing
5ABC notation into images. Assumes that abcm2ps and ImageMagick's
6convert are in the path. Images are put in the abc-images directory.
12from pandoc import toJSONFilter
13from subprocess import Popen, PIPE, call
15imagedir = "abc-images"
18 return hashlib.sha1(x).hexdigest()
20def abc2eps(abc, filetype, outfile):
21 p = Popen(["abcm2ps", "-O", outfile + '.eps', "-"],stdin=PIPE)
25 call(["convert", outfile + '.eps', outfile + '.' + filetype])
27def abc(key, value, format):
28 if key == 'CodeBlock':
29 [[ident,classes,keyvals], code] = value
31 outfile = imagedir + '/' + sha1(code)
34 elif format == "latex":
38 src = outfile + '.' + filetype
39 if not os.path.isfile(src):
42 sys.stderr.write('Created directory ' + imagedir + '\n')
45 abc2eps(code, filetype, outfile)
46 sys.stderr.write('Created image ' + src + '\n')
47 return {'Para': [{'Image': [[], [src,""]]}]}
49if __name__ == "__main__":
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list