pandocfilters-1.4.2/0000755000076500000240000000000013142232130014242 5ustar jgmstaff00000000000000pandocfilters-1.4.2/examples/0000755000076500000240000000000013142232130016060 5ustar jgmstaff00000000000000pandocfilters-1.4.2/examples/abc-sample.md0000644000076500000240000000273112757133333020431 0ustar jgmstaff00000000000000 Use this ``` X:7 T:Qui Tolis (Trio) C:André Raison M:3/4 L:1/4 Q:1/4=92 %%staves {(Pos1 Pos2) Trompette} K:F % V:Pos1 %%MIDI program 78 "Positif"x3 |x3 |c'>ba|Pga/g/f|:g2a |ba2 |g2c- |c2P=B |c>de |fga | V:Pos2 %%MIDI program 78 Mf>ed|cd/c/B|PA2d |ef/e/d |:e2f |ef2 |c>BA |GA/G/F |E>FG |ABc- | V:Trompette %%MIDI program 56 "Trompette"z3|z3 |z3 |z3 |:Mc>BA|PGA/G/F|PE>EF|PEF/E/D|C>CPB,|A,G,F,-| ``` to get ```abc X:7 T:Qui Tolis (Trio) C:André Raison M:3/4 L:1/4 Q:1/4=92 %%staves {(Pos1 Pos2) Trompette} K:F % V:Pos1 %%MIDI program 78 "Positif"x3 |x3 |c'>ba|Pga/g/f|:g2a |ba2 |g2c- |c2P=B |c>de |fga | V:Pos2 %%MIDI program 78 Mf>ed|cd/c/B|PA2d |ef/e/d |:e2f |ef2 |c>BA |GA/G/F |E>FG |ABc- | V:Trompette %%MIDI program 56 "Trompette"z3|z3 |z3 |z3 |:Mc>BA|PGA/G/F|PE>EF|PEF/E/D|C>CPB,|A,G,F,-| ``` See [(this is a link to whatever)](#whatever) for an example with options `{.abc #whatever caption="this is the caption" width=50%}`. ```{.abc #whatever caption="this is the caption" width=50%} X:7 T:Qui Tolis (Trio) C:André Raison M:3/4 L:1/4 Q:1/4=92 %%staves {(Pos1 Pos2) Trompette} K:F % V:Pos1 %%MIDI program 78 "Positif"x3 |x3 |c'>ba|Pga/g/f|:g2a |ba2 |g2c- |c2P=B |c>de |fga | V:Pos2 %%MIDI program 78 Mf>ed|cd/c/B|PA2d |ef/e/d |:e2f |ef2 |c>BA |GA/G/F |E>FG |ABc- | V:Trompette %%MIDI program 56 "Trompette"z3|z3 |z3 |z3 |:Mc>BA|PGA/G/F|PE>EF|PEF/E/D|C>CPB,|A,G,F,-| ``` pandocfilters-1.4.2/examples/abc.py0000755000076500000240000000244312757133333017205 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to process code blocks with class "abc" containing ABC notation into images. Assumes that abcm2ps and ImageMagick's convert are in the path. Images are put in the abc-images directory. """ import os import sys from subprocess import Popen, PIPE, call from pandocfilters import toJSONFilter, Para, Image, get_caption, get_filename4code, get_extension def abc2eps(abc_src, filetype, outfile): p = Popen(["abcm2ps", "-O", outfile + '.eps', "-"], stdin=PIPE) p.stdin.write(abc_src) p.communicate() p.stdin.close() call(["convert", outfile + '.eps', outfile + '.' + filetype]) def abc(key, value, format, _): if key == 'CodeBlock': [[ident, classes, keyvals], code] = value if "abc" in classes: caption, typef, keyvals = get_caption(keyvals) outfile = get_filename4code("abc", code) filetype = get_extension(format, "png", html="png", latex="pdf") dest = outfile + '.' + filetype if not os.path.isfile(dest): abc2eps(code.encode("utf-8"), filetype, outfile) sys.stderr.write('Created image ' + dest + '\n') return Para([Image([ident, [], keyvals], caption, [dest, typef])]) if __name__ == "__main__": toJSONFilter(abc) pandocfilters-1.4.2/examples/caps-sample.md0000644000076500000240000000004512757133333020626 0ustar jgmstaff00000000000000 This is the caps sample with Äüö.pandocfilters-1.4.2/examples/caps.py0000755000076500000240000000047412757133333017410 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to convert all regular text to uppercase. Code, link URLs, etc. are not affected. """ from pandocfilters import toJSONFilter, Str def caps(key, value, format, meta): if key == 'Str': return Str(value.upper()) if __name__ == "__main__": toJSONFilter(caps) pandocfilters-1.4.2/examples/comments-sample.md0000644000076500000240000000020412757133333021522 0ustar jgmstaff00000000000000 Regular text with Äüö. This is a comment with Äüö This is regular text again.pandocfilters-1.4.2/examples/comments.py0000755000076500000240000000141012757133333020276 0ustar jgmstaff00000000000000#!/usr/bin/env python from pandocfilters import toJSONFilter import re """ Pandoc filter that causes everything between '' and '' to be ignored. The comment lines must appear on lines by themselves, with blank lines surrounding them. """ incomment = False def comment(k, v, fmt, meta): global incomment if k == 'RawBlock': fmt, s = v if fmt == "html": if re.search("", s): incomment = True return [] elif re.search("", s): incomment = False return [] if incomment: return [] # suppress anything in a comment if __name__ == "__main__": toJSONFilter(comment) pandocfilters-1.4.2/examples/deemph-sample.md0000644000076500000240000000013512757133333021142 0ustar jgmstaff00000000000000This is the deemph sample. This is *emphasis with Äüö* text which will be shown in caps. pandocfilters-1.4.2/examples/deemph.py0000755000076500000240000000050112757133333017713 0ustar jgmstaff00000000000000#!/usr/bin/env python from pandocfilters import walk, toJSONFilter from caps import caps """ Pandoc filter that causes emphasized text to be displayed in ALL CAPS. """ def deemph(key, val, fmt, meta): if key == 'Emph': return walk(val, caps, fmt, meta) if __name__ == "__main__": toJSONFilter(deemph) pandocfilters-1.4.2/examples/deflists-sample.md0000644000076500000240000000035012757133333021514 0ustar jgmstaff00000000000000Some Definitions Term 1 : Definition 1 Term 2 with *inline markup* : Definition 2 { some code, part of Definition 2 } Third paragraph of definition 2. Term with Äüö : Definition with Äüö Regular Text.pandocfilters-1.4.2/examples/deflists.py0000755000076500000240000000102112757133333020264 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to convert definition lists to bullet lists with the defined terms in strong emphasis (for compatibility with standard markdown). """ from pandocfilters import toJSONFilter, BulletList, Para, Strong def deflists(key, value, format, meta): if key == 'DefinitionList': return BulletList([tobullet(t, d) for [t, d] in value]) def tobullet(term, defs): return([Para([Strong(term)])] + [b for d in defs for b in d]) if __name__ == "__main__": toJSONFilter(deflists) pandocfilters-1.4.2/examples/gabc-sample.md0000644000076500000240000000065312757133333020601 0ustar jgmstaff00000000000000--- header-includes: - \usepackage{libertine} - \usepackage[autocompile]{gregoriotex} --- Use this ~~~~~~ ```gabc (c4) A(f)ve(c) Ma(d)rí(dh'!iv)a.(h.) (::) ``` ~~~~~~ to get ```gabc (c4) A(f)ve(c) Ma(d)rí(dh'!iv)a.(h.) (::) ``` and this ~~~~~~ `gabc-score`{.gabc staffsize=12 annotation=Off. mode=2.} ~~~~~~ to get the score in `gabc-score.gabc` : `gabc-score`{.gabc staffsize=12 annotation=Off. mode=2.} pandocfilters-1.4.2/examples/gabc.py0000755000076500000240000001522313007442045017344 0ustar jgmstaff00000000000000#!/usr/bin/env python3 """ Pandoc filter to convert code blocks with class "gabc" to LaTeX \\gabcsnippet commands in LaTeX output, and to images in HTML output. Assumes Ghostscript, LuaLaTeX, [Gregorio](http://gregorio-project.github.io/) and a reasonable selection of LaTeX packages are installed. """ import os from sys import getfilesystemencoding, stderr from subprocess import Popen, call, PIPE, DEVNULL from hashlib import sha1 from pandocfilters import toJSONFilter, RawBlock, RawInline, Para, Image STDERR = DEVNULL IMAGEDIR = "tmp_gabc" LATEX_DOC = """\\documentclass{article} \\usepackage{libertine} \\usepackage[autocompile,allowdeprecated=false]{gregoriotex} \\catcode`\\℣=\\active \\def ℣#1{{\\Vbar\\hspace{-.25ex}#1}} \\catcode`\\℟=\\active \\def ℟#1{{\\Rbar\\hspace{-.25ex}#1}} \\catcode`\\†=\\active \\def †{{\\GreDagger}} \\catcode`\\✠=\\active \\def ✠{{\\grecross}} \\pagestyle{empty} \\begin{document} %s \\end{document} """ def sha(code): """Returns sha1 hash of the code""" return sha1(code.encode(getfilesystemencoding())).hexdigest() def latex(code): """LaTeX inline""" return RawInline('latex', code) def latexblock(code): """LaTeX block""" return RawBlock('latex', code) def htmlblock(code): """Html block""" return RawBlock('html', code) def latexsnippet(code, kvs, staffsize=17, initiallines=1): """Take in account key/values""" snippet = '' staffsize = int(kvs['staffsize']) if 'staffsize' in kvs \ else staffsize initiallines = int(kvs['initiallines']) if 'initiallines' in kvs \ else initiallines annotationsize = .5 * staffsize if 'mode' in kvs: snippet = ( "\\greannotation{{\\fontsize{%s}{%s}\\selectfont{}%s}}\n" % (annotationsize, annotationsize, kvs['mode']) ) + snippet if 'annotation' in kvs: snippet = ( "\\grechangedim{annotationseparation}{%s mm}{fixed}\n" "\\greannotation{{\\fontsize{%s}{%s}\\selectfont{}%s}}\n" % (staffsize / 60, annotationsize, annotationsize, kvs['annotation']) ) + snippet snippet = ( "\\gresetinitiallines{%s}\n" % initiallines + "\\grechangestaffsize{%s}\n" % staffsize + "\\grechangestyle{initial}{\\fontsize{%s}{%s}\\selectfont{}}" % (2.5 * staffsize, 2.5 * staffsize) ) + snippet snippet = "\\setlength{\\parskip}{0pt}\n" + snippet + code return snippet def latex2png(snippet, outfile): """Compiles a LaTeX snippet to png""" pngimage = os.path.join(IMAGEDIR, outfile + '.png') texdocument = os.path.join(IMAGEDIR, 'tmp.tex') with open(texdocument, 'w') as doc: doc.write(LATEX_DOC % (snippet)) environment = os.environ environment['shell_escape_commands'] = \ "bibtex,bibtex8,kpsewhich,makeindex,mpost,repstopdf,\ gregorio,gregorio-4_2_0" proc = Popen( ["lualatex", '-output-directory=' + IMAGEDIR, texdocument], stdin=PIPE, stdout=STDERR, env=environment ) proc.communicate() proc.stdin.close() call(["pdfcrop", os.path.join(IMAGEDIR, "tmp.pdf")], stdout=STDERR) call( [ "gs", "-sDEVICE=pngalpha", "-r144", "-sOutputFile=" + pngimage, os.path.join(IMAGEDIR, "tmp-crop.pdf"), ], stdout=STDERR, ) def png(contents, latex_command): """Creates a png if needed.""" outfile = sha(contents + latex_command) src = os.path.join(IMAGEDIR, outfile + '.png') if not os.path.isfile(src): try: os.mkdir(IMAGEDIR) stderr.write('Created directory ' + IMAGEDIR + '\n') except OSError: pass latex2png(latex_command + "{" + contents + "}", outfile) stderr.write('Created image ' + src + '\n') return src def properties(meta): try: staffsize = int( meta['music']['c']['gregorio']['c']['staffsize']['c'] ) except (KeyError, TypeError): staffsize = 17 try: initiallines = int( meta['music']['c']['gregorio']['c']['initiallines']['c'] ) except (KeyError, TypeError): initiallines = 1 return staffsize, initiallines def gabc(key, value, fmt, meta): # pylint:disable=I0011,W0613 """Handle gabc file inclusion and gabc code block.""" if key == 'Code': [[ident, classes, kvs], contents] = value # pylint:disable=I0011,W0612 kvs = {key: value for key, value in kvs} if "gabc" in classes: staffsize, initiallines = properties(meta) if fmt == "latex": if ident == "": label = "" else: label = '\\label{' + ident + '}' return latex( "\n\\smallskip\n{%\n" + latexsnippet( '\\gregorioscore{' + contents + '}', kvs, staffsize, initiallines ) + "%\n}" + label ) else: infile = contents + ( '.gabc' if '.gabc' not in contents else '' ) with open(infile, 'r') as doc: code = doc.read().split('%%\n')[1] return [Image(['', [], []], [], [ png( contents, latexsnippet( '\\gregorioscore', kvs, staffsize, initiallines ) ), "" ])] elif key == 'CodeBlock': [[ident, classes, kvs], contents] = value kvs = {key: value for key, value in kvs} if "gabc" in classes: staffsize, initiallines = properties(meta) if fmt == "latex": if ident == "": label = "" else: label = '\\label{' + ident + '}' return [latexblock( "\n\\smallskip\n{%\n" + latexsnippet( '\\gabcsnippet{' + contents + '}', kvs, staffsize, initiallines ) + "%\n}" + label )] else: return Para([Image(['', [], []], [], [ png( contents, latexsnippet( '\\gabcsnippet', kvs, staffsize, initiallines ) ), "" ])]) if __name__ == "__main__": toJSONFilter(gabc) pandocfilters-1.4.2/examples/graphviz-sample.md0000644000076500000240000000062112757133333021532 0ustar jgmstaff00000000000000Use this ``` digraph G {Hello->World} ``` to get ```graphviz digraph G {Hello->World} ``` with with Äüö ```graphviz digraph G {Hello->World with Äüö} ``` See [(this is a link to whatever)](#whatever) for an example with options `{.graphviz #whatever caption="this is the caption" width=35%}`: ```{.graphviz #whatever caption="this is the caption" width=35%} digraph G {Hello->World} ``` pandocfilters-1.4.2/examples/graphviz.py0000755000076500000240000000205213007442045020276 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to process code blocks with class "graphviz" into graphviz-generated images. Needs pygraphviz """ import os import sys import pygraphviz from pandocfilters import toJSONFilter, Para, Image, get_filename4code, get_caption, get_extension, get_value def graphviz(key, value, format, _): if key == 'CodeBlock': [[ident, classes, keyvals], code] = value if "graphviz" in classes: caption, typef, keyvals = get_caption(keyvals) prog, keyvals = get_value(keyvals, u"prog", u"dot") filetype = get_extension(format, "png", html="png", latex="pdf") dest = get_filename4code("graphviz", code, filetype) if not os.path.isfile(dest): g = pygraphviz.AGraph(string=code) g.layout() g.draw(dest, prog=prog) sys.stderr.write('Created image ' + dest + '\n') return Para([Image([ident, [], keyvals], caption, [dest, typef])]) if __name__ == "__main__": toJSONFilter(graphviz) pandocfilters-1.4.2/examples/latexdivs-sample.md0000644000076500000240000000105113007442045021671 0ustar jgmstaff00000000000000\newcommand{\eqn}{\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}}
Turned into a proof environment. $$\eqn$$
First class is picked and converted into a LaTeX environment. $$\eqn$$
Shouldn't be converted into LaTeX environments. Since LaTeX is false.
Also shouldn't be converted into LaTeX environments. Since LaTeX is not present.
pandocfilters-1.4.2/examples/latexdivs.py0000755000076500000240000000160613007442045020453 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to convert divs with latex="true" to LaTeX environments in LaTeX output. The first class will be regarded as the name of the latex environment e.g.
...
will becomes \begin{note}...\end{note} """ from pandocfilters import toJSONFilter, RawBlock, Div def latex(x): return RawBlock('latex', x) def latexdivs(key, value, format, meta): if key == 'Div': [[ident, classes, kvs], contents] = value if ["latex","true"] in kvs: if format == "latex": if ident == "": label = "" else: label = '\\label{' + ident + '}' return([latex('\\begin{' + classes[0] + '}' + label)] + contents + [latex('\\end{' + classes[0] + '}')]) if __name__ == "__main__": toJSONFilter(latexdivs) pandocfilters-1.4.2/examples/lilypond-sample.md0000644000076500000240000000047012757133333021534 0ustar jgmstaff00000000000000--- header-includes: - \usepackage{lyluatex} --- Use this ~~~~~~ ```ly \relative c' { c4 d e f g a b c } ``` ~~~~~~ to get ```ly \relative c' { c4 d e f g a b c } ``` and this ~~~~~~ `lilypond-score`{.ly staffsize=12} ~~~~~~ to get the score in `ly-score.ly` : `lilypond-score`{.ly staffsize=12} pandocfilters-1.4.2/examples/lilypond.py0000755000076500000240000000715312757133333020315 0ustar jgmstaff00000000000000#!/usr/bin/env python3 """ Pandoc filter to process code blocks with class "ly" containing Lilypond notation. Assumes that Lilypond and Ghostscript are installed, plus [lyluatex](https://github.com/jperon/lyluatex) package for LaTeX, with LuaLaTeX. """ import os from sys import getfilesystemencoding, stderr from subprocess import Popen, call, PIPE from hashlib import sha1 from pandocfilters import toJSONFilter, Para, Image, RawInline, RawBlock IMAGEDIR = "tmp_ly" LATEX_DOC = """\\documentclass{article} \\usepackage{libertine} \\usepackage{lyluatex} \\pagestyle{empty} \\begin{document} %s \\end{document} """ def sha(x): return sha1(x.encode(getfilesystemencoding())).hexdigest() def latex(code): """LaTeX inline""" return RawInline('latex', code) def latexblock(code): """LaTeX block""" return RawBlock('latex', code) def ly2png(lily, outfile, staffsize): p = Popen([ "lilypond", "-dno-point-and-click", "-dbackend=eps", "-djob-count=2", "-ddelete-intermediate-files", "-o", outfile, "-" ], stdin=PIPE, stdout=-3) p.stdin.write(("\\paper{\n" "indent=0\\mm\n" "oddFooterMarkup=##f\n" "oddHeaderMarkup=##f\n" "bookTitleMarkup = ##f\n" "scoreTitleMarkup = ##f\n" "}\n" "#(set-global-staff-size %s)\n" % staffsize + lily).encode("utf-8")) p.communicate() p.stdin.close() call([ "gs", "-sDEVICE=pngalpha", "-r144", "-sOutputFile=" + outfile + '.png', outfile + '.pdf', ], stdout=-3) def png(contents, staffsize): """Creates a png if needed.""" outfile = os.path.join(IMAGEDIR, sha(contents + str(staffsize))) src = outfile + '.png' if not os.path.isfile(src): try: os.mkdir(IMAGEDIR) stderr.write('Created directory ' + IMAGEDIR + '\n') except OSError: pass ly2png(contents, outfile, staffsize) stderr.write('Created image ' + src + '\n') return src def lily(key, value, fmt, meta): if key == 'Code': [[ident, classes, kvs], contents] = value # pylint:disable=I0011,W0612 kvs = {key: value for key, value in kvs} if "ly" in classes: staffsize = kvs['staffsize'] if 'staffsize' in kvs else 20 if fmt == "latex": if ident == "": label = "" else: label = '\\label{' + ident + '}' return latex( '\\includely[staffsize=%s]{%s}' % (staffsize, contents) + label ) else: infile = contents + ( '.ly' if '.ly' not in contents else '' ) with open(infile, 'r') as doc: code = doc.read() return [ Image(['', [], []], [], [png(code, staffsize), ""]) ] if key == 'CodeBlock': [[ident, classes, kvs], code] = value kvs = {key: value for key, value in kvs} if "ly" in classes: staffsize = kvs['staffsize'] if 'staffsize' in kvs else 20 if fmt == "latex": if ident == "": label = "" else: label = '\\label{' + ident + '}' return latexblock( '\\lily[staffsize=%s]{%s}' % (staffsize, code) + label ) else: return Para([Image(['', [], []], [], [png(code, staffsize), ""])]) if __name__ == "__main__": toJSONFilter(lily) pandocfilters-1.4.2/examples/Makefile0000644000076500000240000000106312757133333017540 0ustar jgmstaff00000000000000 ALLSAMPLES = $(basename $(wildcard *-sample.md)) ALLPDF = $(addsuffix .pdf,$(ALLSAMPLES)) PYTHON=/usr/bin/python2 all: ${ALLPDF} lilypond-sample.pdf: lilypond-sample.md pandoc --latex-engine lualatex --filter ./$(subst -sample.md,.py,$<) $< -o $@ || touch $@ gabc-sample.pdf: gabc-sample.md pandoc --latex-engine lualatex --filter ./$(subst -sample.md,.py,$<) $< -o $@ || touch $@ %.pdf: %.md echo $(subst -sample.md,.py,$<) pandoc --filter ./$(subst -sample.md,.py,$<) $< -o $@ || touch $@ clean: $(RM) -f ${ALLPDF} *.pyc $(RM) -rf *-images tmp_ly pandocfilters-1.4.2/examples/metavars-sample.md0000644000076500000240000000011212757133333021515 0ustar jgmstaff00000000000000--- author: Caleb Hyde --- # %{author} This was written by %{author} pandocfilters-1.4.2/examples/metavars.py0000755000076500000240000000151712757133333020303 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to allow interpolation of metadata fields into a document. %{fields} will be replaced by the field's value, assuming it is of the type MetaInlines or MetaString. """ from pandocfilters import toJSONFilter, attributes, Span, Str import re pattern = re.compile('%\{(.*)\}$') def metavars(key, value, format, meta): if key == 'Str': m = pattern.match(value) if m: field = m.group(1) result = meta.get(field, {}) if 'MetaInlines' in result['t']: return Span(attributes({'class': 'interpolated', 'field': field}), result['c']) elif 'MetaString' in result[t]: return Str(result['c']) if __name__ == "__main__": toJSONFilter(metavars) pandocfilters-1.4.2/examples/myemph-sample.md0000644000076500000240000000014612757133333021201 0ustar jgmstaff00000000000000\newcommand{\myemph}[1]{ START-MYEMPH #1 END-MYEMPH } This is same text with *emphasis with Äüö*.pandocfilters-1.4.2/examples/myemph.py0000755000076500000240000000072112757133333017754 0ustar jgmstaff00000000000000#!/usr/bin/env python from pandocfilters import toJSONFilter, RawInline """ Pandoc filter that causes emphasis to be rendered using the custom macro '\myemph{...}' rather than '\emph{...}' in latex. Other output formats are unaffected. """ def latex(s): return RawInline('latex', s) def myemph(k, v, f, meta): if k == 'Emph' and f == 'latex': return [latex('\\myemph{')] + v + [latex('}')] if __name__ == "__main__": toJSONFilter(myemph) pandocfilters-1.4.2/examples/plantuml-sample.md0000644000076500000240000000154612757133333021543 0ustar jgmstaff00000000000000Use this ``` Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` to get ```plantuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` with Äüö ```plantuml Älöc -> Bob: Authentication Request Bob --> Älöc: Authentication Response Älöc -> Bob: Another authentication Request Älöc <-- Bob: another authentication Response ``` See [(this is a link to whatever)](#whatever) for an example with options `{.plantuml #whatever caption="this is the caption" width=65%}` ```{.plantuml #whatever caption="this is the caption" width=65%} Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response ``` pandocfilters-1.4.2/examples/plantuml.py0000755000076500000240000000244212757133333020313 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to process code blocks with class "plantuml" into plant-generated images. Needs `plantuml.jar` from http://plantuml.com/. """ import os import sys from subprocess import call from pandocfilters import toJSONFilter, Para, Image, get_filename4code, get_caption, get_extension def plantuml(key, value, format, _): if key == 'CodeBlock': [[ident, classes, keyvals], code] = value if "plantuml" in classes: caption, typef, keyvals = get_caption(keyvals) filename = get_filename4code("plantuml", code) filetype = get_extension(format, "png", html="svg", latex="eps") src = filename + '.uml' dest = filename + '.' + filetype if not os.path.isfile(dest): txt = code.encode(sys.getfilesystemencoding()) if not txt.startswith("@start"): txt = "@startuml\n" + txt + "\n@enduml\n" with open(src, "w") as f: f.write(txt) call(["java", "-jar", "plantuml.jar", "-t"+filetype, src]) sys.stderr.write('Created image ' + dest + '\n') return Para([Image([ident, [], keyvals], caption, [dest, typef])]) if __name__ == "__main__": toJSONFilter(plantuml) pandocfilters-1.4.2/examples/theorem-sample.md0000644000076500000240000000023212757133333021341 0ustar jgmstaff00000000000000--- header-includes: - \newtheorem{theorem}{Theorem} --- Regular Text.
This is my theorem with Äüö.
Regular Text. pandocfilters-1.4.2/examples/theorem.py0000755000076500000240000000225712757133333020126 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to convert divs with class="theorem" to LaTeX theorem environments in LaTeX output, and to numbered theorems in HTML output. """ from pandocfilters import toJSONFilter, RawBlock, Div theoremcount = 0 def latex(x): return RawBlock('latex', x) def html(x): return RawBlock('html', x) def theorems(key, value, format, meta): if key == 'Div': [[ident, classes, kvs], contents] = value if "theorem" in classes: if format == "latex": if ident == "": label = "" else: label = '\\label{' + ident + '}' return([latex('\\begin{theorem}' + label)] + contents + [latex('\\end{theorem}')]) elif format == "html" or format == "html5": global theoremcount theoremcount = theoremcount + 1 newcontents = [html('
Theorem ' + str(theoremcount) + '
'), html('
')] + contents + [html('
\n')] return Div([ident, classes, kvs], newcontents) if __name__ == "__main__": toJSONFilter(theorems) pandocfilters-1.4.2/examples/tikz-sample.md0000644000076500000240000000135112757133333020662 0ustar jgmstaff00000000000000Use this ```latex \begin{tikzpicture} \def \n {5} \def \radius {3cm} \def \margin {8} % margin in angles, depends on the radius \foreach \s in {1,...,\n} { \node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$\s$}; \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius) arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius); } \end{tikzpicture} ``` to get \begin{tikzpicture} \def \n {5} \def \radius {3cm} \def \margin {8} % margin in angles, depends on the radius \foreach \s in {1,...,\n} { \node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$\s$}; \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius) arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius); } \end{tikzpicture} pandocfilters-1.4.2/examples/tikz.py0000755000076500000240000000323512757133333017441 0ustar jgmstaff00000000000000#!/usr/bin/env python """ Pandoc filter to process raw latex tikz environments into images. Assumes that pdflatex is in the path, and that the standalone package is available. Also assumes that ImageMagick's convert is in the path. Images are put in the tikz-images directory. """ import os import re import shutil import sys from subprocess import call from tempfile import mkdtemp from pandocfilters import toJSONFilter, Para, Image, get_filename4code, get_extension def tikz2image(tikz_src, filetype, outfile): tmpdir = mkdtemp() olddir = os.getcwd() os.chdir(tmpdir) f = open('tikz.tex', 'w') f.write("""\\documentclass{standalone} \\usepackage{tikz} \\begin{document} """) f.write(tikz_src) f.write("\n\\end{document}\n") f.close() call(["pdflatex", 'tikz.tex'], stdout=sys.stderr) os.chdir(olddir) if filetype == 'pdf': shutil.copyfile(tmpdir + '/tikz.pdf', outfile + '.pdf') else: call(["convert", tmpdir + '/tikz.pdf', outfile + '.' + filetype]) shutil.rmtree(tmpdir) def tikz(key, value, format, _): if key == 'RawBlock': [fmt, code] = value if fmt == "latex" and re.match("\\\\begin{tikzpicture}", code): outfile = get_filename4code("tikz", code) filetype = get_extension(format, "png", html="png", latex="pdf") src = outfile + '.' + filetype if not os.path.isfile(src): tikz2image(code, filetype, outfile) sys.stderr.write('Created image ' + src + '\n') return Para([Image(['', [], []], [], [src, ""])]) if __name__ == "__main__": toJSONFilter(tikz) pandocfilters-1.4.2/LICENSE0000644000076500000240000000273012757133333015271 0ustar jgmstaff00000000000000Copyright (c) 2013, John MacFarlane All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of John Macfarlane nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pandocfilters-1.4.2/pandocfilters.py0000755000076500000240000002011713027504570017471 0ustar jgmstaff00000000000000# Author: John MacFarlane # Copyright: (C) 2013 John MacFarlane # License: BSD3 """ Functions to aid writing python scripts that process the pandoc AST serialized as JSON. """ import codecs import hashlib import io import json import os import sys # some utility-functions: make it easier to create your own filters def get_filename4code(module, content, ext=None): """Generate filename based on content The function ensures that the (temporary) directory exists, so that the file can be written. Example: filename = get_filename4code("myfilter", code) """ imagedir = module + "-images" fn = hashlib.sha1(content.encode(sys.getfilesystemencoding())).hexdigest() try: os.mkdir(imagedir) sys.stderr.write('Created directory ' + imagedir + '\n') except OSError: pass if ext: fn += "." + ext return os.path.join(imagedir, fn) def get_value(kv, key, value = None): """get value from the keyvalues (options)""" res = [] for k, v in kv: if k == key: value = v else: res.append([k, v]) return value, res def get_caption(kv): """get caption from the keyvalues (options) Example: if key == 'CodeBlock': [[ident, classes, keyvals], code] = value caption, typef, keyvals = get_caption(keyvals) ... return Para([Image([ident, [], keyvals], caption, [filename, typef])]) """ caption = [] typef = "" value, res = get_value(kv, u"caption") if value is not None: caption = [Str(value)] typef = "fig:" return caption, typef, res def get_extension(format, default, **alternates): """get the extension for the result, needs a default and some specialisations Example: filetype = get_extension(format, "png", html="svg", latex="eps") """ try: return alternates[format] except KeyError: return default # end of utilities def walk(x, action, format, meta): """Walk a tree, applying an action to every object. Returns a modified tree. An action is a function of the form `action(key, value, format, meta)`, where: * `key` is the type of the pandoc object (e.g. 'Str', 'Para') `value` is * the contents of the object (e.g. a string for 'Str', a list of inline elements for 'Para') * `format` is the target output format (as supplied by the `format` argument of `walk`) * `meta` is the document's metadata The return of an action is either: * `None`: this means that the object should remain unchanged * a pandoc object: this will replace the original object * a list of pandoc objects: these will replace the original object; the list is merged with the neighbors of the orignal objects (spliced into the list the original object belongs to); returning an empty list deletes the object """ if isinstance(x, list): array = [] for item in x: if isinstance(item, dict) and 't' in item: res = action(item['t'], item['c'] if 'c' in item else None, format, meta) if res is None: array.append(walk(item, action, format, meta)) elif isinstance(res, list): for z in res: array.append(walk(z, action, format, meta)) else: array.append(walk(res, action, format, meta)) else: array.append(walk(item, action, format, meta)) return array elif isinstance(x, dict): for k in x: x[k] = walk(x[k], action, format, meta) return x else: return x def toJSONFilter(action): """Like `toJSONFilters`, but takes a single action as argument. """ toJSONFilters([action]) def toJSONFilters(actions): """Generate a JSON-to-JSON filter from stdin to stdout The filter: * reads a JSON-formatted pandoc document from stdin * transforms it by walking the tree and performing the actions * returns a new JSON-formatted pandoc document to stdout The argument `actions` is a list of functions of the form `action(key, value, format, meta)`, as described in more detail under `walk`. This function calls `applyJSONFilters`, with the `format` argument provided by the first command-line argument, if present. (Pandoc sets this by default when calling filters.) """ try: input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8') except AttributeError: # Python 2 does not have sys.stdin.buffer. # REF: https://stackoverflow.com/questions/2467928/python-unicodeencode input_stream = codecs.getreader("utf-8")(sys.stdin) source = input_stream.read() if len(sys.argv) > 1: format = sys.argv[1] else: format = "" sys.stdout.write(applyJSONFilters(actions, source, format)) def applyJSONFilters(actions, source, format=""): """Walk through JSON structure and apply filters This: * reads a JSON-formatted pandoc document from a source string * transforms it by walking the tree and performing the actions * returns a new JSON-formatted pandoc document as a string The `actions` argument is a list of functions (see `walk` for a full description). The argument `source` is a string encoded JSON object. The argument `format` is a string describing the output format. Returns a the new JSON-formatted pandoc document. """ doc = json.loads(source) if 'meta' in doc: meta = doc['meta'] elif doc[0]: # old API meta = doc[0]['unMeta'] else: meta = {} altered = doc for action in actions: altered = walk(altered, action, format, meta) return json.dumps(altered) def stringify(x): """Walks the tree x and returns concatenated string content, leaving out all formatting. """ result = [] def go(key, val, format, meta): if key in ['Str', 'MetaString']: result.append(val) elif key == 'Code': result.append(val[1]) elif key == 'Math': result.append(val[1]) elif key == 'LineBreak': result.append(" ") elif key == 'SoftBreak': result.append(" ") elif key == 'Space': result.append(" ") walk(x, go, "", {}) return ''.join(result) def attributes(attrs): """Returns an attribute list, constructed from the dictionary attrs. """ attrs = attrs or {} ident = attrs.get("id", "") classes = attrs.get("classes", []) keyvals = [[x, attrs[x]] for x in attrs if (x != "classes" and x != "id")] return [ident, classes, keyvals] def elt(eltType, numargs): def fun(*args): lenargs = len(args) if lenargs != numargs: raise ValueError(eltType + ' expects ' + str(numargs) + ' arguments, but given ' + str(lenargs)) if numargs == 0: xs = [] elif len(args) == 1: xs = args[0] else: xs = list(args) return {'t': eltType, 'c': xs} return fun # Constructors for block elements Plain = elt('Plain', 1) Para = elt('Para', 1) CodeBlock = elt('CodeBlock', 2) RawBlock = elt('RawBlock', 2) BlockQuote = elt('BlockQuote', 1) OrderedList = elt('OrderedList', 2) BulletList = elt('BulletList', 1) DefinitionList = elt('DefinitionList', 1) Header = elt('Header', 3) HorizontalRule = elt('HorizontalRule', 0) Table = elt('Table', 5) Div = elt('Div', 2) Null = elt('Null', 0) # Constructors for inline elements Str = elt('Str', 1) Emph = elt('Emph', 1) Strong = elt('Strong', 1) Strikeout = elt('Strikeout', 1) Superscript = elt('Superscript', 1) Subscript = elt('Subscript', 1) SmallCaps = elt('SmallCaps', 1) Quoted = elt('Quoted', 2) Cite = elt('Cite', 2) Code = elt('Code', 2) Space = elt('Space', 0) LineBreak = elt('LineBreak', 0) Math = elt('Math', 2) RawInline = elt('RawInline', 2) Link = elt('Link', 3) Image = elt('Image', 3) Note = elt('Note', 1) SoftBreak = elt('SoftBreak', 0) Span = elt('Span', 2) pandocfilters-1.4.2/PKG-INFO0000644000076500000240000002163113142232130015342 0ustar jgmstaff00000000000000Metadata-Version: 1.1 Name: pandocfilters Version: 1.4.2 Summary: Utilities for writing pandoc filters in python Home-page: http://github.com/jgm/pandocfilters Author: John MacFarlane Author-email: fiddlosopher@gmail.com License: UNKNOWN Description: pandocfilters ============= A python module for writing `pandoc `_ filters What are pandoc filters? -------------------------- Pandoc filters are pipes that read a JSON serialization of the Pandoc AST from stdin, transform it in some way, and write it to stdout. They can be used with pandoc (>= 1.12) either using pipes :: pandoc -t json -s | ./caps.py | pandoc -f json or using the ``--filter`` (or ``-F``) command-line option. :: pandoc --filter ./caps.py -s For more on pandoc filters, see the pandoc documentation under ``--filter`` and `the tutorial on writing filters`__. __ http://johnmacfarlane.net/pandoc/scripting.html Compatibility ---------------- Pandoc 1.16 introduced link and image `attributes` to the existing `caption` and `target` arguments, requiring a change in pandocfilters that breaks backwards compatibility. Consequently, you should use: - pandocfilters version <= 1.2.4 for pandoc versions 1.12--1.15, and - pandocfilters version >= 1.3.0 for pandoc versions >= 1.16. Pandoc 1.17.3 (pandoc-types 1.17.*) introduced a new JSON format. pandocfilters 1.4.0 should work with both the old and the new format. Installing -------------- Run this inside the present directory:: python setup.py install Or install from PyPI:: pip install pandocfilters Available functions ---------------------- The main functions ``pandocfilters`` exports are - ``walk(x, action, format, meta)`` Walk a tree, applying an action to every object. Returns a modified tree. An action is a function of the form ``action(key, value, format, meta)``, where: - ``key`` is the type of the pandoc object (e.g. 'Str', 'Para') - ``value`` is the contents of the object (e.g. a string for 'Str', a list of inline elements for 'Para') - ``format`` is the target output format (as supplied by the ``format`` argument of ``walk``) - ``meta`` is the document's metadata The return of an action is either: - ``None``: this means that the object should remain unchanged - a pandoc object: this will replace the original object - a list of pandoc objects: these will replace the original object; the list is merged with the neighbors of the orignal objects (spliced into the list the original object belongs to); returning an empty list deletes the object - ``toJSONFilter(action)`` Like ``toJSONFilters``, but takes a single action as argument. - ``toJSONFilters(actions)`` Generate a JSON-to-JSON filter from stdin to stdout The filter: - reads a JSON-formatted pandoc document from stdin - transforms it by walking the tree and performing the actions - returns a new JSON-formatted pandoc document to stdout The argument ``actions`` is a list of functions of the form ``action(key, value, format, meta)``, as described in more detail under ``walk``. This function calls ``applyJSONFilters``, with the ``format`` argument provided by the first command-line argument, if present. (Pandoc sets this by default when calling filters.) - ``applyJSONFilters(actions, source, format="")`` Walk through JSON structure and apply filters This: - reads a JSON-formatted pandoc document from a source string - transforms it by walking the tree and performing the actions - returns a new JSON-formatted pandoc document as a string The ``actions`` argument is a list of functions (see ``walk`` for a full description). The argument ``source`` is a string encoded JSON object. The argument ``format`` is a string describing the output format. Returns a the new JSON-formatted pandoc document. - ``stringify(x)`` Walks the tree x and returns concatenated string content, leaving out all formatting. - ``attributes(attrs)`` Returns an attribute list, constructed from the dictionary attrs. How to use ---------- Most users will only need ``toJSONFilter``. Here is a simple example of its use:: #!/usr/bin/env python """ Pandoc filter to convert all regular text to uppercase. Code, link URLs, etc. are not affected. """ from pandocfilters import toJSONFilter, Str def caps(key, value, format, meta): if key == 'Str': return Str(value.upper()) if __name__ == "__main__": toJSONFilter(caps) Examples -------- The examples subdirectory in the source repository contains the following filters. These filters should provide a useful starting point for developing your own pandocfilters. ``abc.py`` Pandoc filter to process code blocks with class ``abc`` containing ABC notation into images. Assumes that abcm2ps and ImageMagick's convert are in the path. Images are put in the abc-images directory. ``caps.py`` Pandoc filter to convert all regular text to uppercase. Code, link URLs, etc. are not affected. ``comments.py`` Pandoc filter that causes everything between ```` and ```` to be ignored. The comment lines must appear on lines by themselves, with blank lines surrounding ``deemph.py`` Pandoc filter that causes emphasized text to be displayed in ALL CAPS. ``deflists.py`` Pandoc filter to convert definition lists to bullet lists with the defined terms in strong emphasis (for compatibility with standard markdown). ``gabc.py`` Pandoc filter to convert code blocks with class "gabc" to LaTeX \\gabcsnippet commands in LaTeX output, and to images in HTML output. ``graphviz.py`` Pandoc filter to process code blocks with class ``graphviz`` into graphviz-generated images. ``lilypond.py`` Pandoc filter to process code blocks with class "ly" containing Lilypond notation. ``metavars.py`` Pandoc filter to allow interpolation of metadata fields into a document. ``%{fields}`` will be replaced by the field's value, assuming it is of the type ``MetaInlines`` or ``MetaString``. ``myemph.py`` Pandoc filter that causes emphasis to be rendered using the custom macro ``\myemph{...}`` rather than ``\emph{...}`` in latex. Other output formats are unaffected. ``plantuml.py`` Pandoc filter to process code blocks with class ``plantuml`` to images. Needs `plantuml.jar` from http://plantuml.com/. ``theorem.py`` Pandoc filter to convert divs with ``class="theorem"`` to LaTeX theorem environments in LaTeX output, and to numbered theorems in HTML output. ``tikz.py`` Pandoc filter to process raw latex tikz environments into images. Assumes that pdflatex is in the path, and that the standalone package is available. Also assumes that ImageMagick's convert is in the path. Images are put in the ``tikz-images`` directory. Keywords: pandoc Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: End Users/Desktop Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Text Processing :: Filters pandocfilters-1.4.2/README0000644000076500000240000001516713142231157015144 0ustar jgmstaff00000000000000pandocfilters ============= A python module for writing `pandoc `_ filters What are pandoc filters? -------------------------- Pandoc filters are pipes that read a JSON serialization of the Pandoc AST from stdin, transform it in some way, and write it to stdout. They can be used with pandoc (>= 1.12) either using pipes :: pandoc -t json -s | ./caps.py | pandoc -f json or using the ``--filter`` (or ``-F``) command-line option. :: pandoc --filter ./caps.py -s For more on pandoc filters, see the pandoc documentation under ``--filter`` and `the tutorial on writing filters`__. __ http://johnmacfarlane.net/pandoc/scripting.html Compatibility ---------------- Pandoc 1.16 introduced link and image `attributes` to the existing `caption` and `target` arguments, requiring a change in pandocfilters that breaks backwards compatibility. Consequently, you should use: - pandocfilters version <= 1.2.4 for pandoc versions 1.12--1.15, and - pandocfilters version >= 1.3.0 for pandoc versions >= 1.16. Pandoc 1.17.3 (pandoc-types 1.17.*) introduced a new JSON format. pandocfilters 1.4.0 should work with both the old and the new format. Installing -------------- Run this inside the present directory:: python setup.py install Or install from PyPI:: pip install pandocfilters Available functions ---------------------- The main functions ``pandocfilters`` exports are - ``walk(x, action, format, meta)`` Walk a tree, applying an action to every object. Returns a modified tree. An action is a function of the form ``action(key, value, format, meta)``, where: - ``key`` is the type of the pandoc object (e.g. 'Str', 'Para') - ``value`` is the contents of the object (e.g. a string for 'Str', a list of inline elements for 'Para') - ``format`` is the target output format (as supplied by the ``format`` argument of ``walk``) - ``meta`` is the document's metadata The return of an action is either: - ``None``: this means that the object should remain unchanged - a pandoc object: this will replace the original object - a list of pandoc objects: these will replace the original object; the list is merged with the neighbors of the orignal objects (spliced into the list the original object belongs to); returning an empty list deletes the object - ``toJSONFilter(action)`` Like ``toJSONFilters``, but takes a single action as argument. - ``toJSONFilters(actions)`` Generate a JSON-to-JSON filter from stdin to stdout The filter: - reads a JSON-formatted pandoc document from stdin - transforms it by walking the tree and performing the actions - returns a new JSON-formatted pandoc document to stdout The argument ``actions`` is a list of functions of the form ``action(key, value, format, meta)``, as described in more detail under ``walk``. This function calls ``applyJSONFilters``, with the ``format`` argument provided by the first command-line argument, if present. (Pandoc sets this by default when calling filters.) - ``applyJSONFilters(actions, source, format="")`` Walk through JSON structure and apply filters This: - reads a JSON-formatted pandoc document from a source string - transforms it by walking the tree and performing the actions - returns a new JSON-formatted pandoc document as a string The ``actions`` argument is a list of functions (see ``walk`` for a full description). The argument ``source`` is a string encoded JSON object. The argument ``format`` is a string describing the output format. Returns a the new JSON-formatted pandoc document. - ``stringify(x)`` Walks the tree x and returns concatenated string content, leaving out all formatting. - ``attributes(attrs)`` Returns an attribute list, constructed from the dictionary attrs. How to use ---------- Most users will only need ``toJSONFilter``. Here is a simple example of its use:: #!/usr/bin/env python """ Pandoc filter to convert all regular text to uppercase. Code, link URLs, etc. are not affected. """ from pandocfilters import toJSONFilter, Str def caps(key, value, format, meta): if key == 'Str': return Str(value.upper()) if __name__ == "__main__": toJSONFilter(caps) Examples -------- The examples subdirectory in the source repository contains the following filters. These filters should provide a useful starting point for developing your own pandocfilters. ``abc.py`` Pandoc filter to process code blocks with class ``abc`` containing ABC notation into images. Assumes that abcm2ps and ImageMagick's convert are in the path. Images are put in the abc-images directory. ``caps.py`` Pandoc filter to convert all regular text to uppercase. Code, link URLs, etc. are not affected. ``comments.py`` Pandoc filter that causes everything between ```` and ```` to be ignored. The comment lines must appear on lines by themselves, with blank lines surrounding ``deemph.py`` Pandoc filter that causes emphasized text to be displayed in ALL CAPS. ``deflists.py`` Pandoc filter to convert definition lists to bullet lists with the defined terms in strong emphasis (for compatibility with standard markdown). ``gabc.py`` Pandoc filter to convert code blocks with class "gabc" to LaTeX \\gabcsnippet commands in LaTeX output, and to images in HTML output. ``graphviz.py`` Pandoc filter to process code blocks with class ``graphviz`` into graphviz-generated images. ``lilypond.py`` Pandoc filter to process code blocks with class "ly" containing Lilypond notation. ``metavars.py`` Pandoc filter to allow interpolation of metadata fields into a document. ``%{fields}`` will be replaced by the field's value, assuming it is of the type ``MetaInlines`` or ``MetaString``. ``myemph.py`` Pandoc filter that causes emphasis to be rendered using the custom macro ``\myemph{...}`` rather than ``\emph{...}`` in latex. Other output formats are unaffected. ``plantuml.py`` Pandoc filter to process code blocks with class ``plantuml`` to images. Needs `plantuml.jar` from http://plantuml.com/. ``theorem.py`` Pandoc filter to convert divs with ``class="theorem"`` to LaTeX theorem environments in LaTeX output, and to numbered theorems in HTML output. ``tikz.py`` Pandoc filter to process raw latex tikz environments into images. Assumes that pdflatex is in the path, and that the standalone package is available. Also assumes that ImageMagick's convert is in the path. Images are put in the ``tikz-images`` directory. pandocfilters-1.4.2/README.rst0000644000076500000240000000000013142231157022103 1pandocfilters-1.4.2/READMEustar jgmstaff00000000000000pandocfilters-1.4.2/setup.py0000644000076500000240000000157413142231500015763 0ustar jgmstaff00000000000000from distutils.core import setup import os def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup(name='pandocfilters', version='1.4.2', description='Utilities for writing pandoc filters in python', long_description=read('README.rst'), author='John MacFarlane', author_email='fiddlosopher@gmail.com', url='http://github.com/jgm/pandocfilters', py_modules=['pandocfilters'], keywords=['pandoc'], classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Console', 'Intended Audience :: End Users/Desktop', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Text Processing :: Filters' ], )