Package: pandoc-pyrun
pandoc_pyrunPandoc_pyrunis apandocfilter used to executePythoncode embedded in Markdown CodeBlocks.The result of the execution of the Python code is displayed in the
produced documents, for example in PDF or HTML format. Images produced by theturtleandmathplotlibPython libraries can also be included.Options allow to display the Python code and / or the result of its execution.\UsageAn interactive alive console takes the input code, compiles it and displays it to the specific type given, like PDF or Markdown. It can also manageturtleormathplotlibcodes by generating the images, saving them in the current directory and adding the markdow line to incorporate them in the final file.
Code has to betrusted; which means that the code is not verified before any execution, the role of this filter is just to execute the code, not to make sure that it is safe to execute it.To use this filter, you can execute this command template :pandocINPUT_FILE-oOUTPUT_FILE-tOUTPUT_FORMAT-Fpandoc_pyrunExample :pandochello.md-Fpandoc_pyrun-tpdf-ohello_converted.pdfThis can be used to convert into any text pandoc supported format.The only expected source isMarkdownlanguage.\Installationpandoc_pyrunrequiresPythonlanguage.To install the filter, follow the instructions below :InstallPandocon your device withthis link(Optional) InstallLaTeXto transform your markdown into pdf withthis linkInstallGhostscriptforplotandturtlefigures withthis linkNOTE :In yourPATHvariable, make sure you have thebin/folder ofGhostscriptadded, otherwise it won't work.Update your pip withpython -m pip install --upgrade pipInstall this filter withpip install pandoc-pyrun\How to use itOn the top of your document, you'll be able to define global variables for the pandoc_pyrun filter.NOTE :the classes' names and values can be written in both ways : lower case and upper case.---
title: Running your Python CodeBlocks
author: Thomas D'HULST, Ajwad TAYEBI
date: March 29, 2021
pandoc_pyrun_out: OUT
pandoc_pyrun_mode: MODE
pandoc_pyrun_type: TYPE
---Here is a sample of how aCodeBlockhas to be written ; you can also put values (other than defined above) for any pandoc_pyrun classes in the {}.Instead of.pyor.python, you can also write.pandocPyrun.```{.py[thon] out=OUT type=TYPE scope=SCOPE file=FILE}
    #Here you enter your code
    ```\The list of possible values for the above parameters can be found inthe overview tableof the reference_manual.A complete use of this filter is available inthe tutorial.\NB :OnlyCodeBlockcan be read with this filter.If you don't want to let the filter compile your code, add a.pyrunPassbetween the {} explained below.The main goal of its utilisation is to produce, for a code block, its text and/or its execution's result by a Python interpreter.\ExamplesLet's take the following document contentinput.md.```{.python out=NONE}
    def for_all(lst):
        return not False in lst
    ```

    ```{.python out=ALL}
    for_all([])
    for_all((True, True, True))
    for_all((True, False, True))
    ```Here we have forced the out values but the others are set as[default]as indicated in the table above.Now just executepandoc -o output.md input.md -F pandoc_pyrunand then you'll get :::: {.pyrun}
    ::: {.in}
    ``` {.python .pyrunPass}
    for_all([])
    for_all((True, True, True))
    for_all((True, False, True))
    ```
    :::

    ::: {.out}
    ``` {.python .pyrunPass}
    True
    True
    False
    ```
    :::
    :::\Wanna see more ?Check the foldersamples/which contains multiple other examples.Use the commandmaketo generate all examples.Use the commandmake [filename].pdfto generate the chosen example in pdf.Use the commandmake [filename]-out.mdto generate the chosen example in markdown.Use the commandmake cleanto clean all generated files.\HelpAny trouble with our filter ? File an issue or contact us !