pax_global_header00006660000000000000000000000064132604351340014513gustar00rootroot0000000000000052 comment=6e3999d638c0ee5567089f7156794ef4617fd307 pandoc-plantuml-filter-0.1.1/000077500000000000000000000000001326043513400160735ustar00rootroot00000000000000pandoc-plantuml-filter-0.1.1/LICENSE000066400000000000000000000020541326043513400171010ustar00rootroot00000000000000MIT License Copyright (c) 2018 Timo Furrer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pandoc-plantuml-filter-0.1.1/README.md000066400000000000000000000013051326043513400173510ustar00rootroot00000000000000# pandoc-plantuml-filter Pandoc filter which converts PlantUML code blocks to PlantUML images. ```` ```plantuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` ```` ## Usage Install it with pip: ``` pip install pandoc-plantuml-filter ``` And use it like any other pandoc filter: ``` pandoc tests/sample.md -o sample.pdf --filter pandoc-plantuml ``` The PlantUML binary must be in your `$PATH` or can be set with the `PLANTUML_BIN` environment variable. ## But there is ... There are a few other filters trying to convert PlantUML code blocks however they all failed for me. pandoc-plantuml-filter-0.1.1/pandoc_plantuml_filter.py000066400000000000000000000026411326043513400231750ustar00rootroot00000000000000#!/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 import subprocess from pandocfilters import toJSONFilter, Para, Image from pandocfilters import get_filename4code, get_caption, get_extension PLANTUML_BIN = os.environ.get('PLANTUML_BIN', 'plantuml') 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="png") src = filename + '.uml' dest = filename + '.' + filetype if not os.path.isfile(dest): txt = code.encode(sys.getfilesystemencoding()) if not txt.startswith(b"@start"): txt = b"@startuml\n" + txt + b"\n@enduml\n" with open(src, "wb") as f: f.write(txt) subprocess.check_call([ PLANTUML_BIN, "-t" + filetype, src]) sys.stderr.write('Created image ' + dest + '\n') return Para([Image([ident, [], keyvals], caption, [dest, typef])]) def main(): toJSONFilter(plantuml) if __name__ == "__main__": main() pandoc-plantuml-filter-0.1.1/setup.py000066400000000000000000000045221326043513400176100ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys from shutil import rmtree from setuptools import setup, Command here = os.path.abspath(os.path.dirname(__file__)) if sys.argv[-1] == "publish": os.system("python setup.py sdist bdist_wheel upload") sys.exit() required = [ 'pandocfilters' ] class UploadCommand(Command): """Support setup.py upload.""" description = 'Build and publish the package.' user_options = [] @staticmethod def status(s): """Prints things in bold.""" print('\033[1m{0}\033[0m'.format(s)) def initialize_options(self): pass def finalize_options(self): pass def run(self): try: self.status('Removing previous builds…') rmtree(os.path.join(here, 'dist')) except OSError: pass self.status('Building Source and Wheel (universal) distribution…') os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)) self.status('Uploading the package to PyPi via Twine…') os.system('twine upload dist/*') sys.exit() setup( name='pandoc-plantuml-filter', version='0.1.1', description='Pandoc filter for PlantUML code blocks', long_description='Pandoc filter for PlantUML code blocks', author='Timo Furrer', author_email='tuxtimo@gmail.com', url='https://github.com/timofurrer/pandoc-plantuml-filter', install_requires=required, py_modules=['pandoc_plantuml_filter'], entry_points={ 'console_scripts': [ 'pandoc-plantuml = pandoc_plantuml_filter:main' ]}, license='MIT', classifiers=( 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: Implementation', 'Programming Language :: Python :: Implementation :: CPython', 'Topic :: Software Development :: Libraries :: Python Modules' ), cmdclass={ 'upload': UploadCommand, }, ) pandoc-plantuml-filter-0.1.1/tests/000077500000000000000000000000001326043513400172355ustar00rootroot00000000000000pandoc-plantuml-filter-0.1.1/tests/sample.md000066400000000000000000000003341326043513400210400ustar00rootroot00000000000000# Some PantUML sample ```plantuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response ``` Nice, huh?