From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/41182 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: luaTeX and on-the-fly MetaPost compilation Date: Sat, 24 May 2008 09:30:43 +0200 Message-ID: <4837C423.1080800@wxs.nl> 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" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1211614390 3196 80.91.229.12 (24 May 2008 07:33:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 May 2008 07:33:10 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat May 24 09:33:48 2008 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1JzoGB-0000Nj-M1 for gctc-ntg-context-518@m.gmane.org; Sat, 24 May 2008 09:33:47 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 27C6C1FC09; Sat, 24 May 2008 09:33:01 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 27364-01-6; Sat, 24 May 2008 09:32:21 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2FC1B1FC0D; Sat, 24 May 2008 09:31:40 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id BA0F31FC71 for ; Sat, 24 May 2008 09:31:35 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26210-03-5 for ; Sat, 24 May 2008 09:30:59 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with ESMTP id 39E761FC0D for ; Sat, 24 May 2008 09:30:44 +0200 (CEST) Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by controller-1 (SurgeMail 3.9e) with ESMTP id 8215-1840426 for ; Sat, 24 May 2008 09:30:44 +0200 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) In-Reply-To: X-Originating-IP: 10.100.1.100 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 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 X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:41182 Archived-At: Stephan Hennig wrote: > Hi, > > I didn't have the opportunity to touch luaTeX yet, but let me ask one > question in advance: Since luaTeX has a built-in MetaPost interpreter, > is it possible to refer to a certain figure in a MetaPost source file > for inclusion, instead of a compiled figure? > > As an example, I would like to say in a TeX document (syntax may differ) > > \includeMetaPost{foo.2} > > and this should not refer to the pre-compiled file > > foo.2 > > but to section > > figure(2); > ... > endfig; > > in file > > foo.mp > > and compile it on-the-fly. Would that be possible? mplib is still just mp so it ptocessed what is passed to it; no intelligence is added to the mp kernel however, when using the lib ons is in control over what is passed to it in the past i did what you describe in metafun by using just a macro (loadfigure) which filters the image from a file; in luatex we can be more clever (i admit that i hadn;t yet thought of replacing the macro -) using lua we get something ... function filterfromMPblob(data,number) return (data:match(string.format("beginfig%%(%s%%).-endfig",number)) or "") .. " ;" end test this with: str = [[ beginfig(1) draw fullcircle ; endfig ; beginfig(2) draw fullcircle ; endfig ; ]] print(filterfromMPblob(str,2)) glue to tex: \def\includeMetaPost#1#2% io.loaddata is part of l-io.lua {\directlua0{tex.print(filterfromMPblob(io.loaddata("#1",#2)))}} of course this need to be embeded in some general mp support (i'll add it to my todolist; actually a bit more is involved since one probably wants to include the data between the figures too since it may be called upon) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________