ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* reading from standard input
@ 2012-06-08 12:21 <stdin> | Alexandre Leray
  2012-06-08 12:44 ` Hans Hagen
  2012-06-08 13:31 ` Aditya Mahajan
  0 siblings, 2 replies; 4+ messages in thread
From: <stdin> | Alexandre Leray @ 2012-06-08 12:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Hi,

I was wondering if there was a way to make context read from stdin 
instead of reading from a file?

     cat /path/to/src.tex | context --result=/path/to/result.pdf

I'd like to do something like this in python:

     def generate_pdf(self):

         src = """
         \starttext
         \section[éléments-de-transmission]{Éléments de transmission}

         Un module dans lequel une communauté temporaire d'étudiants et
         d'enseignants s'exerce à mettre en situation des réflexions et des
         moments de transmission en interrogeant sans cesse la question de
         l'enseignement. La configuration des enseignants est variable selon
         les situations. Les situations seront mises en place en semaine 
A et B
         selon l'emploi du temps. Chaque nouvelle situation invente sa 
méthode.
         \stoptext
         """
         cmd = 'context --result=/tmp/result.pdf'
         p1 = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE, 
stdin=subprocess.PIPE)
         (stdout, stderr) = p1.communicate(stdin=src)


Thanks,

Alex

-- 
Alexandre Leray
media&  graphic design
http://stdin.fr | http://osp.constantvzw.org/
rue Gallaitstraat 80
1030 Bruxelles
+32 (0)4 87 04 70 30


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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: reading from standard input
  2012-06-08 12:21 reading from standard input <stdin> | Alexandre Leray
@ 2012-06-08 12:44 ` Hans Hagen
  2012-06-08 13:31 ` Aditya Mahajan
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2012-06-08 12:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 8-6-2012 14:21, <stdin> | Alexandre Leray wrote:
> Hi,
>
> I was wondering if there was a way to make context read from stdin
> instead of reading from a file?
>
>      cat /path/to/src.tex | context --result=/path/to/result.pdf
>
> I'd like to do something like this in python:
>
>      def generate_pdf(self):
>
>          src = """
>          \starttext
>          \section[éléments-de-transmission]{Éléments de transmission}
>
>          Un module dans lequel une communauté temporaire d'étudiants et
>          d'enseignants s'exerce à mettre en situation des réflexions et des
>          moments de transmission en interrogeant sans cesse la question de
>          l'enseignement. La configuration des enseignants est variable selon
>          les situations. Les situations seront mises en place en semaine
> A et B
>          selon l'emploi du temps. Chaque nouvelle situation invente sa
> méthode.
>          \stoptext
>          """
>          cmd = 'context --result=/tmp/result.pdf'
>          p1 = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE,
> stdin=subprocess.PIPE)
>          (stdout, stderr) = p1.communicate(stdin=src)
>

you can use the standard tex input readers (\read) as well as io.read 
when you're in lua

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: reading from standard input
  2012-06-08 12:21 reading from standard input <stdin> | Alexandre Leray
  2012-06-08 12:44 ` Hans Hagen
@ 2012-06-08 13:31 ` Aditya Mahajan
  2012-06-08 14:32   ` <stdin> | Alexandre Leray
  1 sibling, 1 reply; 4+ messages in thread
From: Aditya Mahajan @ 2012-06-08 13:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1564 bytes --]

On Fri, 8 Jun 2012, <stdin> | Alexandre Leray wrote:

> Hi,
>
> I was wondering if there was a way to make context read from stdin instead of 
> reading from a file?
>
>    cat /path/to/src.tex | context --result=/path/to/result.pdf
>
> I'd like to do something like this in python:
>
>    def generate_pdf(self):
>
>        src = """
>        \starttext
>        \section[éléments-de-transmission]{Éléments de transmission}
>
>        Un module dans lequel une communauté temporaire d'étudiants et
>        d'enseignants s'exerce à mettre en situation des réflexions et des
>        moments de transmission en interrogeant sans cesse la question de
>        l'enseignement. La configuration des enseignants est variable selon
>        les situations. Les situations seront mises en place en semaine A et 
> B
>        selon l'emploi du temps. Chaque nouvelle situation invente sa 
> méthode.
>        \stoptext
>        """
>        cmd = 'context --result=/tmp/result.pdf'
>        p1 = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE, 
> stdin=subprocess.PIPE)
>        (stdout, stderr) = p1.communicate(stdin=src)
>

You can try context --pipe --result=/tmp/result.pdf but that only runs the 
document once, so cross referencings, TOC, etc won't work correctly. The 
other options is to write to a file, and then run "context --purgeall 
--result=/tmp/result.pdf filename"; this will run the document appropriate 
number of times, and then delete the temp files, leaving only the .tex and 
the .pdf file.

Aditya

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: reading from standard input
  2012-06-08 13:31 ` Aditya Mahajan
@ 2012-06-08 14:32   ` <stdin> | Alexandre Leray
  0 siblings, 0 replies; 4+ messages in thread
From: <stdin> | Alexandre Leray @ 2012-06-08 14:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Thank you,

I will try this!

Alex

On 08/06/2012 15:31, Aditya Mahajan wrote:
> On Fri, 8 Jun 2012, <stdin> | Alexandre Leray wrote:
>
>> Hi,
>>
>> I was wondering if there was a way to make context read from stdin 
>> instead of reading from a file?
>>
>>    cat /path/to/src.tex | context --result=/path/to/result.pdf
>>
>> I'd like to do something like this in python:
>>
>>    def generate_pdf(self):
>>
>>        src = """
>>        \starttext
>>        \section[éléments-de-transmission]{Éléments de transmission}
>>
>>        Un module dans lequel une communauté temporaire d'étudiants et
>>        d'enseignants s'exerce à mettre en situation des réflexions et 
>> des
>>        moments de transmission en interrogeant sans cesse la question de
>>        l'enseignement. La configuration des enseignants est variable 
>> selon
>>        les situations. Les situations seront mises en place en 
>> semaine A et B
>>        selon l'emploi du temps. Chaque nouvelle situation invente sa 
>> méthode.
>>        \stoptext
>>        """
>>        cmd = 'context --result=/tmp/result.pdf'
>>        p1 = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE, 
>> stdin=subprocess.PIPE)
>>        (stdout, stderr) = p1.communicate(stdin=src)
>>
>
> You can try context --pipe --result=/tmp/result.pdf but that only runs 
> the document once, so cross referencings, TOC, etc won't work 
> correctly. The other options is to write to a file, and then run 
> "context --purgeall --result=/tmp/result.pdf filename"; this will run 
> the document appropriate number of times, and then delete the temp 
> files, leaving only the .tex and the .pdf file.
>
> Aditya
>
>
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

-- 
Alexandre Leray
media&  graphic design
http://stdin.fr | http://osp.constantvzw.org/
rue Gallaitstraat 80
1030 Bruxelles
+32 (0)4 87 04 70 30


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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2012-06-08 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08 12:21 reading from standard input <stdin> | Alexandre Leray
2012-06-08 12:44 ` Hans Hagen
2012-06-08 13:31 ` Aditya Mahajan
2012-06-08 14:32   ` <stdin> | Alexandre Leray

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).