From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/56338 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: [OT] ASCII text output Date: Wed, 17 Feb 2010 14:27:53 -0500 (EST) Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1266434891 13976 80.91.229.12 (17 Feb 2010 19:28:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Feb 2010 19:28:11 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Feb 17 20:28:08 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NhpZ8-0006yB-ID for gctc-ntg-context-518@m.gmane.org; Wed, 17 Feb 2010 20:28:06 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 85477C9D10; Wed, 17 Feb 2010 20:28:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MtFDKGQvc3Z6; Wed, 17 Feb 2010 20:28:03 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id B36A2C9D13; Wed, 17 Feb 2010 20:28:02 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0799FC9D13 for ; Wed, 17 Feb 2010 20:28:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jsxDwkTcUmen for ; Wed, 17 Feb 2010 20:27:57 +0100 (CET) Original-Received: from hackers.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.14.81]) by balder.ntg.nl (Postfix) with ESMTP id 1F4FDC9D10 for ; Wed, 17 Feb 2010 20:27:56 +0100 (CET) Original-Received: FROM [192.168.2.8] (c-76-28-91-31.hsd1.ct.comcast.net [76.28.91.31]) By hackers.mr.itd.umich.edu ID 4B7C433B.21008.16614 ; Authuser adityam; 17 Feb 2010 14:27:55 EST In-Reply-To: User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 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:56338 Archived-At: Hi Roger, On Tue, 16 Feb 2010, Roger Mason wrote: > Aditya Mahajan writes: > >> On Tue, 16 Feb 2010, Roger Mason wrote: >> >>> I need to convert an exam written in ConTeXt to an ascii text file like >>> the following: >>> >>> >>> Before I go to the trouble of creating a parser to read the ConTeXt >>> input and write the desired output I'm wondering if this can be done >>> with ConTeXt itself. >> >> Can you show a small example of the corresponding tex source? > > \def\mcquestionnumber{14} > > > \mcquestionheader A ruby is a gem of corundum coloured by\crlf > {$A$}: Rutile\crlf{$B$}: Calcium (Ca)\crlf{$C$}: Chromium (Cr)\crlf{$D$}: Iron (Fe) and Titanium (Ti)\crlf > > \mcquestionfooter If you are willing to add more markup, then TeX can do the parsing for you. \startquestion[title={Ruby coloured by}, points=1, difficulty=1] A ruby is a gem of corundum colored \startoptions \option Rutile \option Calcium \correctoption Chrumium \option Iron and Titanium \stopoptions \starthint .... \stophint \startfeedback ... \stopfeedback \stopquestion You can create a mode for ascii output that redefines all the environments to *typeset* the correct output, which you can then convert to text using pdftotext. Another option is to write everything in XML (it is almost the same ...) A ruby .. .... ... With a few setup commands, ConTeXt can directly typeset an xml file. Parsing the xml file to generate ascii text can be done using your favourite programming language (or using ConTeXt by typesetting the desired output and using pdftotext). > And the desired output is... > > NewQuestion,MC, > Title,Ruby coloured by, > QuestionText,A ruby is a gem of corundum coloured by > Points,1, > Difficulty,1, > Image,, > Option,0,Rutile,, > Option,0,Calcium (Ca),, > Option,100,Chromium (Cr),, > Option,0,Iron (Fe) and Titanium (Ti),, > Hint,,,, > Feedback,,,, > > Maybe a regexp would do, followed by a bit of hand editing, but if there > is a way of doing this in ConTeXt that would be very convenient. If this is something that you need to do only a few types, anything quick and dirty will suffice. But for the long run it makes sense to have a more detailed markup and then you do not need to worry about the correctness of the conversion. 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 ___________________________________________________________________________________