ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* adding module to ConTeXt basic installation
@ 2021-11-06 10:55 A A via ntg-context
  2021-11-06 20:01 ` Bruce Horrocks via ntg-context
  2021-11-07 16:38 ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 4+ messages in thread
From: A A via ntg-context @ 2021-11-06 10:55 UTC (permalink / raw)
  To: ntg-context; +Cc: A A


[-- Attachment #1.1: Type: text/plain, Size: 371 bytes --]

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.

Regards,

Amine

[-- Attachment #1.2: Type: text/html, Size: 650 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: adding module to ConTeXt basic installation
  2021-11-06 10:55 adding module to ConTeXt basic installation A A via ntg-context
@ 2021-11-06 20:01 ` Bruce Horrocks via ntg-context
  2021-11-11  9:06   ` Denis Maier via ntg-context
  2021-11-07 16:38 ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 4+ messages in thread
From: Bruce Horrocks via ntg-context @ 2021-11-06 20:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Bruce Horrocks

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: adding module to ConTeXt basic installation
  2021-11-06 10:55 adding module to ConTeXt basic installation A A via ntg-context
  2021-11-06 20:01 ` Bruce Horrocks via ntg-context
@ 2021-11-07 16:38 ` Hans Hagen via ntg-context
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2021-11-07 16:38 UTC (permalink / raw)
  To: ntg-context; +Cc: Hans Hagen

On 11/6/2021 11:55 AM, A A via ntg-context wrote:
> Dear All,
> 
> I installed ConTeXt on my windows machine using the instructions 
> provided here:
> 
>   - https://wiki.contextgarden.net/Installation 
> <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 
> <https://github.com/adityam/filter>
> 
> How do I add this module to my current installation? Thanks for your 
> consideration.
normally they can be put in the texmf-modules tree btu you can also put 
them in texmf-local

just make sure they are in tex/context/modules/... or so amd run 
"context --generate" to update the file database

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: adding module to ConTeXt basic installation
  2021-11-06 20:01 ` Bruce Horrocks via ntg-context
@ 2021-11-11  9:06   ` Denis Maier via ntg-context
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Maier via ntg-context @ 2021-11-11  9:06 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier

Bruce,
I think what the Amine is referring to with "render" is running the code through an external program, and including the result of that external process in your document. Something like this: 
%%%%%%%%%%%%%%%%%%%%%%%%%
The result of 1 + 1 is \pythoncode{1 + 1}
%%%%%%%%%%%%%%%%%%%%%%%%%

The filter module can be used to execute the pythoncode include the result in your context document. So, you'll end up with:
%%%%%%%%%%%%%%%%%%%%%%%%%
The result of 1 + 1 is 2
%%%%%%%%%%%%%%%%%%%%%%%%%

Denis

> -----Ursprüngliche Nachricht-----
> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Bruce
> Horrocks via ntg-context
> Gesendet: Samstag, 6. November 2021 21:02
> An: mailing list for ConTeXt users <ntg-context@ntg.nl>
> Cc: Bruce Horrocks <ntg@scorecrow.com>
> Betreff: Re: [NTG-context] adding module to ConTeXt basic installation
> 
> 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/c
> ontext-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
> __________________________________________________________
> _________________________
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-11  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06 10:55 adding module to ConTeXt basic installation A A via ntg-context
2021-11-06 20:01 ` Bruce Horrocks via ntg-context
2021-11-11  9:06   ` Denis Maier via ntg-context
2021-11-07 16:38 ` Hans Hagen via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).