On 6 Nov 2021, at 10:55, A A via ntg-context <ntg-context@ntg.nl> wrote:
> 
> Dear All,
> 
> I installed ConTeXt on my windows machine using the instructions provided 
> here:
> 
>  - https://wiki.contextgarden.net/Installation
> 
> I would like to now render some python code in my pdf. For this I need to 
> install this module: https://github.com/adityam/filter  
> 
> How do I add this module to my current installation? Thanks for your 
> consideration.

I'm not quite sure what you mean by 'render' Python code. If you just mean to 
typeset it using a monospaced font so that the indentation is preserved then a 
simple \definetyping is probably all that you need.

e.g.
\definetyping[PythonSource][style=\mono]
\starttext
This is taken from Rosetta Code:\par
\startPythonSource
def eratosthenes2(n):
    multiples = set()
    for i in range(2, n+1):
        if i not in multiples:
            yield i
            multiples.update(range(i*i, n+1, i))
 
print(list(eratosthenes2(100)))
\stopPythonSource
\stoptext

If the source code is in a file then you can read the file directly with:
\typefile [PythonSource] [ ] {filename.py}

If you wanted to typeset your code with syntax highlighting/colouring then 
there are more advanced options to \definetyping that can be used and there is 
also the Vim module.
<https://anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/context/contrib/context-vim/doc/context/third/vim/vim.txt>

Regards,
—
Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to