From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/72417 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: feature request Date: Mon, 14 Nov 2011 15:03:19 +0100 Message-ID: <4EC11FA7.6070402@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="iso-8859-1"; Format="flowed" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1321279451 21407 80.91.229.12 (14 Nov 2011 14:04:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 14 Nov 2011 14:04:11 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Nov 14 15:04:06 2011 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 1RPx8n-0001FG-Bd for gctc-ntg-context-518@m.gmane.org; Mon, 14 Nov 2011 15:04:05 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id CB084CB0E3; Mon, 14 Nov 2011 15:04:04 +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 LcaBZOQdCV5v; Mon, 14 Nov 2011 15:03:59 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 40349CB0D4; Mon, 14 Nov 2011 15:03:59 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A2D50CB0D4 for ; Mon, 14 Nov 2011 15:03:58 +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 AZU-Ty+K9Qqo for ; Mon, 14 Nov 2011 15:03:47 +0100 (CET) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id 2591BCB0C3 for ; Mon, 14 Nov 2011 15:03:47 +0100 (CET) Original-Received: from smtp.ziggozakelijk.nl (D57D1DA2.static.ziggozakelijk.nl [213.125.29.162]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id pAEE3jT7023674 for ; Mon, 14 Nov 2011 15:03:46 +0100 X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.100; Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by pragma-net.nl (SurgeMail 5.3h2) with ESMTP (TLS) id 4968-1713362 for multiple; Mon, 14 Nov 2011 15:03:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-Authenticated-User: hagen@controller-9 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=213.125.29.162; country=NL; region=11; city=Den Haag; latitude=52.0833; longitude=4.3000; http://maps.google.com/maps?q=52.0833,4.3000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0xFV23Kii - 745129ea2b34 - 20111114 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 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:72417 Archived-At: On 14-11-2011 09:47, Aditya Mahajan wrote: > On Fri, 11 Nov 2011, Steffen Wolfrum wrote: > >> quite often I wish we could have a kind of in line comment: >> Something like =BFthis is my comment=A1 this. >> >> I assume it is not trivial due to catcode issues, to say the least. >> But nevertheless, as it is getting close to christmas, I just wanted >> to mention this idea here. > > As long as there is no line break in the comment, the following lua > based solution works (inspired by m-translate) > > \startluacode > local comments =3D {} > thirddata =3D thirddata or {} > > thirddata.comments =3D comments > > function comments.translate(s) > return string.gsub(s, "=BF.-=A1","") > end > > local textlineactions =3D resolvers.openers.helpers.textlineactions > utilities.sequencers.appendaction(textlineactions,"after","thirddata.comm= ents.translate") > > > function comments.enable() > utilities.sequencers.enableaction(textlineactions,"thirddata.comments.tra= nslate") > > end > > function comments.disable() > utilities.sequencers.disableaction(textlineactions,"thirddata.comments.tr= anslate") > > end > > comments.disable() > \stopluacode > > \def\enablecomments {\ctxlua{thirddata.comments.enable()}} > \def\disablecomments{\ctxlua{thirddata.comments.disable()}} > > \appendtoks > \enablecomments > \to \everystarttext > > \starttext > \section{An =BFin \iffalse comment=A1 works} > Multiple =BFin \iffalse comment=A1 with something =BFin \iffalse comment= =A1 in > betweeen > \stoptext or ... \startluacode thirddata =3D thirddata or { } local comments =3D { filters =3D { } } thirddata.comments =3D comments local textlineactions =3D resolvers.openers.helpers.textlineactions local sequencers =3D utilities.sequencers local constants =3D interfaces.constants local gsub, find, format =3D string.gsub, string.find, string.format function comments.install(name,settings) local settings =3D utilities.parsers.settings_to_hash(settings) local start =3D string.escapedpattern(settings[constants.start] = or "") local stop =3D string.escapedpattern(settings[constants.stop] or "= ") if start ~=3D "" and stop ~=3D "" then local pattern =3D start .. ".-" .. stop comments.filters[name] =3D function(s) if s =3D=3D "" then return "" elseif find(s,start) then return (gsub(s,pattern,"")) else return s end end = sequencers.appendaction(textlineactions,"after",format("thirddata.comments.= filters.%s",name)) comments.disable(name) end end function comments.enable(name) = sequencers.enableaction(textlineactions,format("thirddata.comments.filters.= %s",name)) end function comments.disable(name) = sequencers.disableaction(textlineactions,format("thirddata.comments.filters= .%s",name)) end \stopluacode \unprotect \unexpanded\def\installcomments{\dodoubleargument\doinstallcomments} \def\doinstallcomments[#1][#2]% = {\ctxlua{thirddata.comments.install(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)= }} \unexpanded\def\enablecomments[#1]% {\ctxlua{thirddata.comments.enable (\!!bs#1\!!es)}} \unexpanded\def\disablecomments[#1]% {\ctxlua{thirddata.comments.disable(\!!bs#1\!!es)}} \protect \installcomments[test] [start=3D=BF,stop=3D=A1] \installcomments[test2][start=3D=A1,stop=3D=BF] \enablecomments[test] \enablecomments[test2] \starttext \section{An =BFin \iffalse comment=A1 works} Multiple =BFin \iffalse comment=A1 with something =BFin \iffalse comment= =A1 in = betweeen oeps =BFoeps=A1 oeps =A1oeps=BF oeps \stoptext ----------------------------------------------------------------- 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 t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________