Skip to main content
filter_pandoc_run_py
====================

|Build Status| |Coverage Status| |PyPI version| |PyPI format| |License|
|Python version| |Development Status|

*filter_pandoc_run_py* is a `pandoc <http://pandoc.org/>`__ filter for
execute python codes written in ``CodeBlocks`` or inline ``Code``. It
receives the print statement output and place it to the markdown
converted file. Also, it save any created pyplot figure to a folder and
include it as an image. Code has to be **trusted**

.. raw:: html

<!-- https://github.com/chdemko/pandoc-latex-fontsize as reference -->

Usage
-----

To apply the filter, use the following option with pandoc:

::

pandoc INPUT_FILE -F filter_pandoc_run_py --to OUTPUT_FORMAT -o OUTPUT_FILE

Example:

::

pandoc ./tests/test.md -F filter_pandoc_run_py -t gfm -o test_converted.md

- You can convert it to any pandoc supported format;
- When converted to a markdown format it can change some part of the
text to conform with the default style (e.g. changing setext-style
headers to ATX headers).

Installation
------------

*filter_pandoc_run_py* requires [python] (tested in version > 3.0)

Install *filter_pandoc_run_py* as root using the bash command

::

git clone URL
cd dir
pip install .

Or get it from PYPI:

::

pip install filter_pandoc_run_py

How to Use It
-------------

Create a regular markdown code but appending a class .run to it.

For ``CodeBlock``
~~~~~~~~~~~~~~~~~

Output print statement as a BlockQuote or paragraph. You can hide the
generation code.

Syntax:
``{.python .run format=[blockquote (default), text] hide_code=[False (default), True] }``

The following syntax is also support for enabling standard IDE code
highlight:

::

```python
#filter: {.run format=[blockquote (default), text] hide_code=[False (default), True] }
.... code ....
```

“Pretty print” enable: output of print statement is converted and is
rendered

For ``Code``
~~~~~~~~~~~~

Output print statement as inline text.

The syntax is:

::

`print(code)`{.run}

“Pretty print” enable: output of print statement is converted and is
rendered

Example
-------

From a markdown file such as:

::

```{.python .run}
d = 1e3
m = 2 * d
print('The total mass is {:.2f} $m^3$'.format(m))
```

``pandoc FILE --to markdown -F filter_pandoc_run_py.py -o OUTFILE.md``

.. code:: markdown

> Output:
>
> > The total mass is 2000.00 $m^3$

Generating pyplot images embedded in markdown file:

::

```{.python .run caption="Figure Number One" label="my_fig"}
import matplotlib
matplotlib.use('AGG')
from matplotlib import pyplot as plt
plt.plot([1, 2], [3, 4], 'dr-')
```

More examples
~~~~~~~~~~~~~

- Check files ``./tests/test.md`` and ``./tests/test_common_mark.md``

Getting Help
------------

If you have any difficulties with *filter_pandoc_run_py*, please feel
welcome to `file an
issue <https://github.com/caiofcm/filter_pandoc_run_py/issues>`__ on
github so that we can help.

.. |Build Status| image:: https://img.shields.io/travis/caiofcm/filter_pandoc_run_py/master.svg
:target: https://travis-ci.org/caiofcm/filter_pandoc_run_py/branches
.. |Coverage Status| image:: https://coveralls.io/repos/github/caiofcm/filter_pandoc_run_py/badge.svg?branch=master
:target: https://coveralls.io/github/caiofcm/filter_pandoc_run_py?branch=master
.. |PyPI version| image:: https://img.shields.io/pypi/v/filter_pandoc_run_py.svg
:target: https://pypi.org/project/filter_pandoc_run_py/
.. |PyPI format| image:: https://img.shields.io/pypi/format/filter_pandoc_run_py.svg
:target: https://pypi.org/project/filter_pandoc_run_py/
.. |License| image:: https://img.shields.io/pypi/l/filter_pandoc_run_py.svg
:target: https://raw.githubusercontent.com/caiofcm/filter_pandoc_run_py/master/LICENSE
.. |Python version| image:: https://img.shields.io/pypi/pyversions/filter_pandoc_run_py.svg
:target: https://pypi.org/project/filter_pandoc_run_py/
.. |Development Status| image:: https://img.shields.io/pypi/status/filter_pandoc_run_py.svg
:target: https://pypi.org/project/filter_pandoc_run_py/

Metadata

Release files for filter_pandoc_run_py 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for filter_pandoc_run_py 0.6.2
File Size Uploaded Provenance Actions
filter_pandoc_run_py-0.6.2.tar.gz 6.6 kB Without provenance Details for filter_pandoc_run_py-0.6.2.tar.gz

Release files / filter_pandoc_run_py-0.6.2.tar.gz

Download URL filter_pandoc_run_py-0.6.2.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7c28d4595ad0ed7abebfb4be85a84144c416296abe92f4aa06b9ff80665c803e
BLAKE2b-256 checksum
How to use checksums
fff11d5e9a92052567ce6a48203c0ff92a310179f09f841c438ff31c228bd544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for filter_pandoc_run_py 0.6.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page