From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/76804 Path: news.gmane.org!not-for-mail From: " | Alexandre Leray" Newsgroups: gmane.comp.tex.context Subject: Re: reading from standard input Date: Fri, 08 Jun 2012 16:32:07 +0200 Message-ID: <4FD20CE7.4080802@stdin.fr> References: <4FD1EE44.2030302@stdin.fr> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0829930696==" X-Trace: dough.gmane.org 1339165534 29870 80.91.229.3 (8 Jun 2012 14:25:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 8 Jun 2012 14:25:34 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Jun 08 16:25:34 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sd083-0000wT-DC for gctc-ntg-context-518@m.gmane.org; Fri, 08 Jun 2012 16:25:31 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A80AC101DD; Fri, 8 Jun 2012 16:25:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dPY17FFokNc1; Fri, 8 Jun 2012 16:25:28 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AE497101E2; Fri, 8 Jun 2012 16:25:28 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 420FA101E2 for ; Fri, 8 Jun 2012 16:25:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id SSmSbxeHNcN4 for ; Fri, 8 Jun 2012 16:25:22 +0200 (CEST) Original-Received: from filter1-nij.mf.surf.net (filter1-nij.mf.surf.net [195.169.124.152]) by balder.ntg.nl (Postfix) with ESMTP id 05F29101DD for ; Fri, 8 Jun 2012 16:25:21 +0200 (CEST) Original-Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by filter1-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q58EPKIv008670 for ; Fri, 8 Jun 2012 16:25:21 +0200 X-Originating-IP: 217.70.178.144 Original-Received: from mfilter16-d.gandi.net (mfilter16-d.gandi.net [217.70.178.144]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 72C1A1720C2; Fri, 8 Jun 2012 16:24:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter16-d.gandi.net Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter16-d.gandi.net (mfilter16-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id IubhPM6EtK9k; Fri, 8 Jun 2012 16:24:38 +0200 (CEST) X-Originating-IP: 91.183.56.178 Original-Received: from [192.168.0.157] (unknown [91.183.56.178]) (Authenticated sender: alexandre@stdin.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 9AE0A172076; Fri, 8 Jun 2012 16:24:38 +0200 (CEST) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=217.70.183.196; country=FR; latitude=46.0000; longitude=2.0000; http://maps.google.com/maps?q=46.0000,2.0000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 07HjOpky9 - 70a83b08140f - 20120608 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.152 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.13 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:76804 Archived-At: This is a multi-part message in MIME format. --===============0829930696== Content-Type: multipart/alternative; boundary="------------090505030709020107060702" This is a multi-part message in MIME format. --------------090505030709020107060702 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Thank you, I will try this! Alex On 08/06/2012 15:31, Aditya Mahajan wrote: > On Fri, 8 Jun 2012, | Alexandre Leray wrote: > >> Hi, >> >> I was wondering if there was a way to make context read from stdin=20 >> instead of reading from a file? >> >> cat /path/to/src.tex | context --result=3D/path/to/result.pdf >> >> I'd like to do something like this in python: >> >> def generate_pdf(self): >> >> src =3D """ >> \starttext >> \section[=E9l=E9ments-de-transmission]{=C9l=E9ments de transmis= sion} >> >> Un module dans lequel une communaut=E9 temporaire d'=E9tudiants= et >> d'enseignants s'exerce =E0 mettre en situation des r=E9flexions= et=20 >> des >> moments de transmission en interrogeant sans cesse la question = de >> l'enseignement. La configuration des enseignants est variable=20 >> selon >> les situations. Les situations seront mises en place en=20 >> semaine A et B >> selon l'emploi du temps. Chaque nouvelle situation invente sa=20 >> m=E9thode. >> \stoptext >> """ >> cmd =3D 'context --result=3D/tmp/result.pdf' >> p1 =3D subprocess.Popen(cmd.split(" "), stdout=3Dsubprocess.PIP= E,=20 >> stdin=3Dsubprocess.PIPE) >> (stdout, stderr) =3D p1.communicate(stdin=3Dsrc) >> > > You can try context --pipe --result=3D/tmp/result.pdf but that only run= s=20 > the document once, so cross referencings, TOC, etc won't work=20 > correctly. The other options is to write to a file, and then run=20 > "context --purgeall --result=3D/tmp/result.pdf filename"; this will run= =20 > the document appropriate number of times, and then delete the temp=20 > 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 > _______________________________________________________________________= ____________ --=20 Alexandre Leray media& graphic design http://stdin.fr | http://osp.constantvzw.org/ rue Gallaitstraat 80 1030 Bruxelles +32 (0)4 87 04 70 30 --------------090505030709020107060702 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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
--------------090505030709020107060702-- --===============0829930696== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0829930696==--