From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/101552 Path: news.gmane.org!.POSTED!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: How can I remove a blank leading line from a buffer Date: Sun, 12 Aug 2018 23:44:56 -0400 (EDT) Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="0-2092048605-1534131897=:804" X-Trace: blaine.gmane.org 1534131793 29069 195.159.176.226 (13 Aug 2018 03:43:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 13 Aug 2018 03:43:13 +0000 (UTC) User-Agent: Alpine 2.20 (OSX 67 2015-01-07) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Aug 13 05:43:09 2018 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fp3l6-0007TN-TN for gctc-ntg-context-518@m.gmane.org; Mon, 13 Aug 2018 05:43:09 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id DD3FB4FD5A; Mon, 13 Aug 2018 05:45:12 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ni6Bb6zwDVba; Mon, 13 Aug 2018 05:45:11 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D219A4FD22; Mon, 13 Aug 2018 05:45:11 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 34A834FD22 for ; Mon, 13 Aug 2018 05:45:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yi-4Wdrobvdh for ; Mon, 13 Aug 2018 05:45:10 +0200 (CEST) Original-Received: from maleficent.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.125.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id A30C04FD1A for ; Mon, 13 Aug 2018 05:44:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=relay-2016-05-12; t=1534131898; bh=8PS1X7Geyfae/tyxQ9WrHQ7wx33vgaG5nao+5iZbPkc=; h=Date:From:To:Subject:In-Reply-To:References; b=MHbWimohwKVnM+eTylm3zgg0IzvRcIgiqm22crp1K23oKeNWYcuI8s4LHmgLMkgSB /zPj9GSsvuPV3wMApPqDg6plTdDOPWuXCNFkoySLRKluCYJf4RYNU41/9R3Htx9F6m DagRnrkY491Vt5/J6hSyKnnXqbI6GYfwCh37wArtTAVpWVqt3BdWScFRapK3I/zqph zfm0Z1MHJTaQgBciRGlDrIDHYZc84rpk6Yrjd9D6qhLv85YOXWW9HA2xKKDV1w4XtH qaRiSEA5q9w/cX/na1u6MFyt7+9UzyYBg0+yt1L/cP20+d97pBpF2QV8fYdrfiTJzn OSrGX/s69+Jig== Authentication-Results: maleficent.mr.itd.umich.edu; iprev=pass policy.iprev=198.84.249.206 (198-84-249-206.cpe.teksavvy.com); auth=pass smtp.auth=adityam Original-Received: FROM [192.168.0.14] (198-84-249-206.cpe.teksavvy.com [198.84.249.206]) By maleficent.mr.itd.umich.edu ID 5B70FEBA.2261.26355; Authuser adityam; Sun, 12 Aug 2018 23:44:58 -0400 In-Reply-To: X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:101552 Archived-At: --0-2092048605-1534131897=:804 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Sun, 12 Aug 2018, Rik Kabel wrote: > %% How can one remove blank lines at the start of a buffer so that > %% commands that grab a buffer can be used in the same way as, for > %% example, \startparagraph...\stopparagraph, which allow blank > %% lines around the content? > %% > %% The problem appears when an optional argument is allowed but none > %% is provided. Adding \relax does not help; adding empty brackets > %% does. I see no way to distinguish between a buffer without > %% leading blank lines and a buffer that was created when brackets > %% are provided. > %% > %% \inlinebuffer handles the leading blank lines when there is > %% nothing prepended, but I need to prepend. (It also handles the > %% unwanted trailing line, but that is not an issue here). > %% > %% How can I unpack the buffer, apply the equivalent functions of > %% ignorespaspaces and removeunwantedspaces to it, and repack it? > %% The buffer may contain internal blank lines and macros, and > %% those should be retained. Or, is there already a function to > %% strip a buffer in the manner that string.strip does a string? > > \setupwhitespace[none] > \setupindenting[none] > \define\Mark{\color[middlegray]{\itb=C2=BF\ }} > \define\First{nothing yet} > \define\Arg{nothing yet} > \setuplanguage[en][spacing=3Dpacked] > > \starttexdefinition unexpanded startBufTest > \bgroup > \dosingleempty\dostartBufTest > \stoptexdefinition > > \starttexdefinition dostartBufTest [#SETUPS] > \doifsomethingelse{#{SETUPS}} > {\define\Arg{yes}} > {\define\Arg{no}} > \iffirstargument > \define\First{yes} > \else > \define\First{no} > \fi > \relax > \getrawparameters[BufTest][xx=3Dyy,#SETUPS] > \grabbufferdata[TestBuffer][startBufTest][stopBufTest] > \stoptexdefinition > > \starttexdefinition stopBufTest > > \startparagraph > > \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer] > \ (first: \First, arg: \Arg) > > \stopparagraph > > \egroup > \stoptexdefinition > > \starttext > > \startparagraph > > A starting paragraph. > > \stopparagraph > > \startBufTest > Buffer without blank lines. > \stopBufTest > > \startparagraph > > An intervening paragraph. > > \stopparagraph > > \startBufTest > > Buffer with blank lines. > > \stopBufTest > > \startparagraph > > An intervening paragraph. > > \stopparagraph > > \startBufTest\relax > > Buffer with \tex{relax}. > > \stopBufTest > > \startparagraph > > An intervening paragraph. > > \stopparagraph > > \startBufTest[] > > Buffer with \type{[]}. > > \stopBufTest > > \startparagraph > > An intervening paragraph. > > \stopparagraph > > \startBufTest[key=3Dvalue] > > Buffer with \type{[key=3Dvalue]}. > > \stopBufTest > > \startparagraph > > A closing paragraph. > > \stopparagraph > > \stoptext > > \stopmode Perhaps \ignorespaces might work, but I often find that the conceptually=20 simplest solution is to post-process the buffer at the lua end. See http://wiki.contextgarden.net/Programming_in_LuaTeX#Manipulating_verbatim_t= ext for an example. Aditya --0-2092048605-1534131897=:804 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --0-2092048605-1534131897=:804--