From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/55497 Path: news.gmane.org!not-for-mail From: Tad Ashlock Newsgroups: gmane.comp.tex.context Subject: Re: Automated Quotation/Punctuation Placement Date: Fri, 08 Jan 2010 14:50:30 -0700 Message-ID: <4B47A8A6.8040604@cyberdude.com> References: <4B475CF9.1050305@cyberdude.com> <20100108170141.GA2153@khaled-laptop> 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 1262987459 15040 80.91.229.12 (8 Jan 2010 21:50:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Jan 2010 21:50:59 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Jan 08 22:50:52 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.50) id 1NTMjM-0008QM-19 for gctc-ntg-context-518@m.gmane.org; Fri, 08 Jan 2010 22:50:52 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id CCBC9C9CAF; Fri, 8 Jan 2010 22:50:51 +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 e69s2HL9c+fX; Fri, 8 Jan 2010 22:50:48 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2BA26C9C85; Fri, 8 Jan 2010 22:50:48 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 163C3C9C85 for ; Fri, 8 Jan 2010 22:50:46 +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 J8CxsHNsI4yd for ; Fri, 8 Jan 2010 22:50:42 +0100 (CET) Original-Received: from omspl-da01.mx.aol.com (omspl-da01.mx.aol.com [205.188.170.51]) by balder.ntg.nl (Postfix) with ESMTP id 73151C9BC9 for ; Fri, 8 Jan 2010 22:50:42 +0100 (CET) Original-Received: from rly-dh03.mx.aol.com (rly-dh03.mx.aol.com [205.188.157.7]) by omspl-da01.mx.aol.com (OMS Interface) with ESMTP id 6EE7538000327; Fri, 8 Jan 2010 16:50:41 -0500 (EST) Original-Received: from [127.0.0.1] (71-210-199-37.albq.qwest.net [71.210.199.37]) by rly-dh03.mx.aol.com (WebSuites/MUA Thirdparty client Interface) with ESMTPA id 6855A38000081; Fri, 8 Jan 2010 16:50:39 -0500 (EST) User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) In-Reply-To: <20100108170141.GA2153@khaled-laptop> X-Antivirus: avast! (VPS 100108-1, 01/08/2010), Outbound message X-Antivirus-Status: Clean x-aol-global-disposition: S X-AOL-SCOLL-SCORE: 0:2:397209600:93952408 X-AOL-SCOLL-URL_COUNT: 0 x-aol-sid: 3039cdbc9d074b47a8af733f 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:55497 Archived-At: Khaled Hosny wrote: > On Fri, Jan 08, 2010 at 09:27:37AM -0700, Tad Ashlock wrote: >> >> ========================== >> \startluacode >> function move_end_punctuation (text, punc, cmd_start, cmd_mid, cmd_end) >> context(cmd_start .. text .. cmd_mid) >> if string.find('.,!?', punc, 1, true) then >> context(punc .. cmd_end) >> else >> context(cmd_end .. ' ' .. punc) >> end >> end >> \stopluacode >> >> \def\Var#1#2{\ctxlua{move_end_punctuation([==[#1]==],[==[#2]==], >> '\\quote{\\type{','}','}')}} >> >> \starttext >> >> This is \Var{var_name}, a variable. >> >> \stoptext >> ========================== > What about: > > > \def\Var#1#2{'\type{#1}% > \directlua{ > if "#2" == "," then > tex.sprint("#2'") > else > tex.sprint("'#2") > end}} > > > \Var{555}, hello \Var{666}. \Var{666}\par > Thank you, Khaled, for the response. This solution works as is. But it has a problem as soon as you want to put double quotes around the variable name. Simply replacing the single quotes with double quotes in your solution doesn't produce open- and close-quotes pairs: ================== \def\Var#1#2{"\type{#1}% \directlua{ if "#2" == "," then tex.sprint('#2"') else tex.sprint('"#2') end}} ================== In order to do that, you need (I think) to use the \quotation{} command: ================== \def\Var#1#2{\quotation{\type{#1}% \directlua{ if "#2" == "," then tex.sprint("#2}") else tex.sprint("}#2") end}} ================== resulting in: ================== ! Too many }'s. l.7 end}} ================== I also tried \bgroup...\egroup: ================== \def\Var#1#2{\quotation\bgroup\type{#1}% \directlua{ if "#2" == "," then tex.sprint("#2\egroup ") else tex.sprint("\egroup #2") end}} ================== giving: ================== ! Missing } inserted. } \normalend l.18 \stoptext ================== Thanks again! Tad ___________________________________________________________________________________ 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 ___________________________________________________________________________________