* How can I remove a blank leading line from a buffer
@ 2018-08-13 3:18 Rik Kabel
2018-08-13 3:44 ` Aditya Mahajan
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 3:18 UTC (permalink / raw)
To: mailing list for ConTeXt users
%% 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¿\ }}
\define\First{nothing yet}
\define\Arg{nothing yet}
\setuplanguage[en][spacing=packed]
\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=yy,#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=value]
Buffer with \type{[key=value]}.
\stopBufTest
\startparagraph
A closing paragraph.
\stopparagraph
\stoptext
\stopmode
%% --
%% Rik Kabel
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 3:18 How can I remove a blank leading line from a buffer Rik Kabel
@ 2018-08-13 3:44 ` Aditya Mahajan
2018-08-13 3:46 ` Henri Menke
2018-08-13 7:01 ` Hans Hagen
2 siblings, 0 replies; 20+ messages in thread
From: Aditya Mahajan @ 2018-08-13 3:44 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 3232 bytes --]
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¿\ }}
> \define\First{nothing yet}
> \define\Arg{nothing yet}
> \setuplanguage[en][spacing=packed]
>
> \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=yy,#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=value]
>
> Buffer with \type{[key=value]}.
>
> \stopBufTest
>
> \startparagraph
>
> A closing paragraph.
>
> \stopparagraph
>
> \stoptext
>
> \stopmode
Perhaps \ignorespaces might work, but I often find that the conceptually
simplest solution is to post-process the buffer at the lua end. See
http://wiki.contextgarden.net/Programming_in_LuaTeX#Manipulating_verbatim_text
for an example.
Aditya
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 3:18 How can I remove a blank leading line from a buffer Rik Kabel
2018-08-13 3:44 ` Aditya Mahajan
@ 2018-08-13 3:46 ` Henri Menke
2018-08-13 7:02 ` Hans Hagen
2018-08-13 7:01 ` Hans Hagen
2 siblings, 1 reply; 20+ messages in thread
From: Henri Menke @ 2018-08-13 3:46 UTC (permalink / raw)
To: ntg-context
On 13/08/18 15:18, 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¿\ }}
> \define\First{nothing yet}
> \define\Arg{nothing yet}
> \setuplanguage[en][spacing=packed]
>
> \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=yy,#SETUPS]
> \grabbufferdata[TestBuffer][startBufTest][stopBufTest]
> \stoptexdefinition
>
> \starttexdefinition stopBufTest
>
> \startparagraph
>
% Ignore first \par
\def\par{\let\par\normalpar}
> \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=value]
>
> Buffer with \type{[key=value]}.
>
> \stopBufTest
>
> \startparagraph
>
> A closing paragraph.
>
> \stopparagraph
>
> \stoptext
>
> \stopmode
>
> %% --
> %% Rik Kabel
>
> ___________________________________________________________________________________
>
> 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://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 3:18 How can I remove a blank leading line from a buffer Rik Kabel
2018-08-13 3:44 ` Aditya Mahajan
2018-08-13 3:46 ` Henri Menke
@ 2018-08-13 7:01 ` Hans Hagen
2018-08-13 14:28 ` Rik Kabel
2 siblings, 1 reply; 20+ messages in thread
From: Hans Hagen @ 2018-08-13 7:01 UTC (permalink / raw)
To: mailing list for ConTeXt users, Rik Kabel
On 8/13/2018 5:18 AM, 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¿\ }}
> \define\First{nothing yet}
> \define\Arg{nothing yet}
> \setuplanguage[en][spacing=packed]
>
> \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=yy,#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=value]
>
> Buffer with \type{[key=value]}.
>
> \stopBufTest
>
> \startparagraph
>
> A closing paragraph.
>
> \stopparagraph
>
> \stoptext
\startparagraph
% \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer]
% \ (first: \First, arg: \Arg)
\margintext{\Mark}
\setupparagraphintro[first][(first: \First, arg: \Arg)]
%\setupparagraphintro[next][(first: \First, arg: \Arg)]
\getbuffer[TestBuffer]
\stopparagraph
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 3:46 ` Henri Menke
@ 2018-08-13 7:02 ` Hans Hagen
0 siblings, 0 replies; 20+ messages in thread
From: Hans Hagen @ 2018-08-13 7:02 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 8/13/2018 5:46 AM, Henri Menke wrote:
> % Ignore first \par
> \def\par{\let\par\normalpar}
Sort of dangerous ... redefining such core commands or primitives can
have side effects as one never knows what explicit \par's are issued.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 7:01 ` Hans Hagen
@ 2018-08-13 14:28 ` Rik Kabel
2018-08-13 16:04 ` Wolfgang Schuster
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 14:28 UTC (permalink / raw)
To: Hans Hagen, mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 4428 bytes --]
On 8/13/2018 03:01, Hans Hagen wrote:
> On 8/13/2018 5:18 AM, 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¿\ }}
>> \define\First{nothing yet}
>> \define\Arg{nothing yet}
>> \setuplanguage[en][spacing=packed]
>>
>> \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=yy,#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=value]
>>
>> Buffer with \type{[key=value]}.
>>
>> \stopBufTest
>>
>> \startparagraph
>>
>> A closing paragraph.
>>
>> \stopparagraph
>>
>> \stoptext
>
> \startparagraph
>
> % \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer]
> % \ (first: \First, arg: \Arg)
>
> \margintext{\Mark}
>
> \setupparagraphintro[first][(first: \First, arg: \Arg)]
> %\setupparagraphintro[next][(first: \First, arg: \Arg)]
>
> \getbuffer[TestBuffer]
>
> \stopparagraph
Hans,
That works for the over-simplified case here, but fails in practice. For
a \startnarrower[left] paragraph, the mark is still in the main margin,
not the 'margin' of the narrowed paragraph. Also, the placement of the
text in the margin is wrong and not easily controlled as with \llap and
\rlap. The code started out more like:
\define\Mark{\color[middlegray]{\hskip.6cm\itb¿\ }}
\setwidthof{\Mark}\to\MarkWidth
...
\starttexdefinition stopBufTest
\startluacode
buffers.prepend("TestBuffer","\\dontleavehmode\\llap{\\Mark}")
\stopluacode
\setupnarrower[left=\MarkWidth]
\startnarrower[left,right]
\startparagraph
\inlinebuffer[TestBuffer]
\stopparagraph
\stopnarrower
\egroup
\stoptexdefinition
So I am still looking for a way to do this. Meanwhile I am trying to
understand Aditya's examples.
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 7356 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 14:28 ` Rik Kabel
@ 2018-08-13 16:04 ` Wolfgang Schuster
2018-08-13 17:09 ` Rik Kabel
2018-08-13 16:15 ` Rik Kabel
2018-08-13 17:51 ` Rik Kabel
2 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2018-08-13 16:04 UTC (permalink / raw)
To: mailing list for ConTeXt users, Rik Kabel
[-- Attachment #1.1: Type: text/plain, Size: 961 bytes --]
Rik Kabel schrieb am 13.08.18 um 16:28:
> Hans,
>
> That works for the over-simplified case here, but fails in practice.
> For a \startnarrower[left] paragraph, the mark is still in the main
> margin, not the 'margin' of the narrowed paragraph. Also, the
> placement of the text in the margin is wrong and not easily controlled
> as with \llap and \rlap. The code started out more like:
>
> \define\Mark{\color[middlegray]{\hskip.6cm\itb¿\ }}
> \setwidthof{\Mark}\to\MarkWidth
> ...
> \starttexdefinition stopBufTest
> \startluacode
> buffers.prepend("TestBuffer","\\dontleavehmode\\llap{\\Mark}")
> \stopluacode
> \setupnarrower[left=\MarkWidth]
> \startnarrower[left,right]
> \startparagraph
> \inlinebuffer[TestBuffer]
> \stopparagraph
> \stopnarrower
> \egroup
> \stoptexdefinition
>
Hi Rik,
what do you want to achieve and why do you need a buffer for it?
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 1613 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 14:28 ` Rik Kabel
2018-08-13 16:04 ` Wolfgang Schuster
@ 2018-08-13 16:15 ` Rik Kabel
2018-08-13 17:51 ` Rik Kabel
2 siblings, 0 replies; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 16:15 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 2374 bytes --]
On 8/13/2018 10:28, Rik Kabel wrote:
> On 8/13/2018 03:01, Hans Hagen wrote:
>> On 8/13/2018 5:18 AM, Rik Kabel wrote:
>>
>> \startparagraph
>>
>> % \dontleavehmode\llap{\Mark}\inlinebuffer[TestBuffer]
>> % \ (first: \First, arg: \Arg)
>>
>> \margintext{\Mark}
>>
>> \setupparagraphintro[first][(first: \First, arg: \Arg)]
>> %\setupparagraphintro[next][(first: \First, arg: \Arg)]
>>
>> \getbuffer[TestBuffer]
>>
>> \stopparagraph
>
> Hans,
>
> That works for the over-simplified case here, but fails in practice.
> For a \startnarrower[left] paragraph, the mark is still in the main
> margin, not the 'margin' of the narrowed paragraph. Also, the
> placement of the text in the margin is wrong and not easily controlled
> as with \llap and \rlap. The code started out more like:
>
> \define\Mark{\color[middlegray]{\hskip.6cm\itb¿\ }}
> \setwidthof{\Mark}\to\MarkWidth
> ...
> \starttexdefinition stopBufTest
> \startluacode
> buffers.prepend("TestBuffer","\\dontleavehmode\\llap{\\Mark}")
> \stopluacode
> \setupnarrower[left=\MarkWidth]
> \startnarrower[left,right]
> \startparagraph
> \inlinebuffer[TestBuffer]
> \stopparagraph
> \stopnarrower
> \egroup
> \stoptexdefinition
>
>
> So I am still looking for a way to do this. Meanwhile I am trying to
> understand Aditya's examples.
Turns out another answer was hidden in Hans's reply. The following seems
to meet my needs, but it may complicate other use of
\setupparagraphintro (which I don't recall seeing before), so it may not
be a generic solution.
An empty string works fine instead of the llaped marking shown here.
This is a less dangerous hack than redefining \par, but still may fail
in more complex documents when \setupparagraphintro is used elsewhere.
\starttexdefinition stopBufTest
\startnarrower[left,right]
\startparagraph
\setupparagraphintro[first][\llap{\Mark}]
\inlinebuffer[TestBuffer] \ (first: \First, arg: \Arg)
\stopparagraph
\stopnarrower
\egroup
\stoptexdefinition
Thank you, Hans.
(For a non-hack generic solution that does not interfere with other use
of \setupparagraphintro, surely there must be an easy way to apply
string.strip to the buffer.)
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 3732 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 16:04 ` Wolfgang Schuster
@ 2018-08-13 17:09 ` Rik Kabel
2018-08-13 17:46 ` Wolfgang Schuster
0 siblings, 1 reply; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 17:09 UTC (permalink / raw)
To: Wolfgang Schuster, mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 2675 bytes --]
On 8/13/2018 12:04, Wolfgang Schuster wrote:
>
> Hi Rik,
>
> what do you want to achieve and why do you need a buffer for it?
>
> Wolfgang
>
Fair question.
I have a document with many (400+) block quotations. Each consists of a
text extract, which may be prose or poetry, and additional optional
components (alternate versions or transliterations, translations,
attribution). The optional components are distinguished typographically
– enlarged square brackets around alternate versions, enlarged
parentheses around translations, leading en-dash and hanging indent for
attributions. Each component is in a buffer. The structure looks like:
\startBlockQuotation[label=abc,authors={...},precis={short
extract},translators={...},tprecis={{short extract},{short extract}}...]
\startExtract[language=agr,align=yes,font=abc,tolerance=...,...]
text of extract
\stopExtract
\startTransliteration[language=en,align=yes,font=abc,...]
text of transliteration
\stopTransliteration
\startTranslation[...]
text of translation
\stopTranslation
\startAttribution[tolerance=,...]
attribution of quotation
\stopAttribution
\stopBlockQuotation
and the code to handle it generates author index entries, a quotation
precis index, and so on from the attributes of the envelope, and
typesets each component based on the provided settings or defaults,
placing the appropriate decorations around those components that call
for them. The components are nestable, so one extract may contain
another, and components can be used separately without the envelope
(\startBlockQuotation or \startEpigraph) as well.
(I have written it this way to ease the move to an XML-based format for
storing the quotations. I realize I am combining presentation elements,
like label, tolerance, and precis, and content elements, like language,
and some that may be either, like align and font, in the attributes, but
will deal with that later.)
I prefer to leave blank lines around blocks of text and around macro
commands, so:
\startparagraph
some text
\stopparagraph
but when this is done with, for example, \startAttribution, and no
optional arguments are provided, I run into the problem I have described.
I realize that I can simply not include the blank line after
\startAttribution. I would prefer, however, to see consistent parallel
structures without having to distinguish them at the time it is written.
Perhaps I am being too picky, but that is what I am attempting.
At this point, the \setupparagraphintro hack handles my needs, so I will
proceed with that.
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 3754 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 17:09 ` Rik Kabel
@ 2018-08-13 17:46 ` Wolfgang Schuster
2018-08-13 18:27 ` Rik Kabel
0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2018-08-13 17:46 UTC (permalink / raw)
To: Rik Kabel; +Cc: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 3078 bytes --]
Rik Kabel schrieb am 13.08.18 um 19:09:
> On 8/13/2018 12:04, Wolfgang Schuster wrote:
>>
>> Hi Rik,
>>
>> what do you want to achieve and why do you need a buffer for it?
>>
>> Wolfgang
>>
> Fair question.
>
> I have a document with many (400+) block quotations. Each consists of
> a text extract, which may be prose or poetry, and additional optional
> components (alternate versions or transliterations, translations,
> attribution). The optional components are distinguished
> typographically – enlarged square brackets around alternate versions,
> enlarged parentheses around translations, leading en-dash and hanging
> indent for attributions. Each component is in a buffer. The structure
> looks like:
>
> \startBlockQuotation[label=abc,authors={...},precis={short
> extract},translators={...},tprecis={{short extract},{short
> extract}}...]
>
> \startExtract[language=agr,align=yes,font=abc,tolerance=...,...]
>
> text of extract
>
> \stopExtract
>
> \startTransliteration[language=en,align=yes,font=abc,...]
>
> text of transliteration
>
> \stopTransliteration
>
> \startTranslation[...]
>
> text of translation
>
> \stopTranslation
>
> \startAttribution[tolerance=,...]
>
> attribution of quotation
>
> \stopAttribution
>
> \stopBlockQuotation
>
> and the code to handle it generates author index entries, a quotation
> precis index, and so on from the attributes of the envelope, and
> typesets each component based on the provided settings or defaults,
> placing the appropriate decorations around those components that call
> for them. The components are nestable, so one extract may contain
> another, and components can be used separately without the envelope
> (\startBlockQuotation or \startEpigraph) as well.
>
> (I have written it this way to ease the move to an XML-based format
> for storing the quotations. I realize I am combining presentation
> elements, like label, tolerance, and precis, and content elements,
> like language, and some that may be either, like align and font, in
> the attributes, but will deal with that later.)
>
> I prefer to leave blank lines around blocks of text and around macro
> commands, so:
>
> \startparagraph
>
> some text
>
> \stopparagraph
>
> but when this is done with, for example, \startAttribution, and no
> optional arguments are provided, I run into the problem I have described.
Try to avoid blank lines at the begin/end of environments.
> I realize that I can simply not include the blank line after
> \startAttribution. I would prefer, however, to see consistent parallel
> structures without having to distinguish them at the time it is
> written. Perhaps I am being too picky, but that is what I am attempting.
>
> At this point, the \setupparagraphintro hack handles my needs, so I
> will proceed with that.
\starttext
\BeforePar{\dontleavehmode\llap{? }}\GotoPar
\input knuth
\startnarrower
\BeforePar{\dontleavehmode\llap{? }}\GotoPar
\input knuth
\stopnarrower
\stoptext
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 4375 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 14:28 ` Rik Kabel
2018-08-13 16:04 ` Wolfgang Schuster
2018-08-13 16:15 ` Rik Kabel
@ 2018-08-13 17:51 ` Rik Kabel
2 siblings, 0 replies; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 17:51 UTC (permalink / raw)
To: ntg-context
On 8/13/2018 10:28, Rik Kabel wrote:
> That works for the over-simplified case here, but fails in practice.
> For a \startnarrower[left] paragraph, the mark is still in the main
> margin, not the 'margin' of the narrowed paragraph. Also, the
> placement of the text in the margin is wrong and not easily controlled
> as with \llap and \rlap. The code started out more like:
>
Correcting the record: I misspoke in part above; margintext does follow
the narrowed paragraph shape.
--
Rik
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 17:46 ` Wolfgang Schuster
@ 2018-08-13 18:27 ` Rik Kabel
2018-08-13 19:52 ` Wolfgang Schuster
0 siblings, 1 reply; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 18:27 UTC (permalink / raw)
To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1265 bytes --]
On 8/13/2018 13:46, Wolfgang Schuster wrote:
>
> \starttext
>
> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>
> \input knuth
>
> \startnarrower
>
> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>
> \input knuth
>
> \stopnarrower
>
> \stoptext
>
> Wolfgang
I am applying it incorrectly, or it does not work with the buffers
created by \grabbufferdata:
\setupwhitespace[none]
\setupindenting[none]
\starttexdefinition unexpanded startBufTest
\bgroup
\dosingleempty\dostartBufTest
\stoptexdefinition
\starttexdefinition dostartBufTest [#SETUPS]
\getrawparameters[BufTest][xx=yy,#SETUPS]
\grabbufferdata[TestBuffer][startBufTest][stopBufTest]
\stoptexdefinition
\starttexdefinition stopBufTest
\startnarrower[left,right]
\startparagraph
\BeforePar{\dontleavehmode\llap{? }}\GotoPar
\inlinebuffer[TestBuffer]
\stopparagraph
\stopnarrower
\egroup
\stoptexdefinition
\starttext
\startBufTest
Buffer without blank lines.
\stopBufTest
\startBufTest
Buffer with blank lines.
\stopBufTest
\startBufTest[key=value]
Buffer with \type{[key=value]}.
\stopBufTest
\stoptext
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 2408 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 18:27 ` Rik Kabel
@ 2018-08-13 19:52 ` Wolfgang Schuster
2018-08-13 22:43 ` Rik Kabel
0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2018-08-13 19:52 UTC (permalink / raw)
To: Rik Kabel; +Cc: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1314 bytes --]
Rik Kabel schrieb am 13.08.18 um 20:27:
> On 8/13/2018 13:46, Wolfgang Schuster wrote:
>>
>> \starttext
>>
>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>
>> \input knuth
>>
>> \startnarrower
>>
>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>
>> \input knuth
>>
>> \stopnarrower
>>
>> \stoptext
>>
>> Wolfgang
>
> I am applying it incorrectly, or it does not work with the buffers
> created by \grabbufferdata:
>
> \setupwhitespace[none]
> \setupindenting[none]
> \starttexdefinition unexpanded startBufTest
> \bgroup
> \dosingleempty\dostartBufTest
> \stoptexdefinition
> \starttexdefinition dostartBufTest [#SETUPS]
> \getrawparameters[BufTest][xx=yy,#SETUPS]
> \grabbufferdata[TestBuffer][startBufTest][stopBufTest]
> \stoptexdefinition
> \starttexdefinition stopBufTest
> \startnarrower[left,right]
> \startparagraph
> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
> \inlinebuffer[TestBuffer]
> \stopparagraph
> \stopnarrower
> \egroup
> \stoptexdefinition
>
\starttexdefinition stopBufTest
\startnarrower[left,right]
\startparagraph
\dontleavehmode\llap{? }%
\blank[overlay]
\inlinebuffer[TestBuffer]
\stopparagraph
\stopnarrower
\egroup
\stoptexdefinition
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 2393 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 19:52 ` Wolfgang Schuster
@ 2018-08-13 22:43 ` Rik Kabel
2018-08-14 14:46 ` Rik Kabel
0 siblings, 1 reply; 20+ messages in thread
From: Rik Kabel @ 2018-08-13 22:43 UTC (permalink / raw)
To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1960 bytes --]
On 8/13/2018 15:52, Wolfgang Schuster wrote:
>
>
> Rik Kabel schrieb am 13.08.18 um 20:27:
>> On 8/13/2018 13:46, Wolfgang Schuster wrote:
>>>
>>> \starttext
>>>
>>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>>
>>> \input knuth
>>>
>>> \startnarrower
>>>
>>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>>
>>> \input knuth
>>>
>>> \stopnarrower
>>>
>>> \stoptext
>>>
>>> Wolfgang
>>
>> I am applying it incorrectly, or it does not work with the buffers
>> created by \grabbufferdata:
>>
>> \setupwhitespace[none]
>> \setupindenting[none]
>> \starttexdefinition unexpanded startBufTest
>> \bgroup
>> \dosingleempty\dostartBufTest
>> \stoptexdefinition
>> \starttexdefinition dostartBufTest [#SETUPS]
>> \getrawparameters[BufTest][xx=yy,#SETUPS]
>> \grabbufferdata[TestBuffer][startBufTest][stopBufTest]
>> \stoptexdefinition
>> \starttexdefinition stopBufTest
>> \startnarrower[left,right]
>> \startparagraph
>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>> \inlinebuffer[TestBuffer]
>> \stopparagraph
>> \stopnarrower
>> \egroup
>> \stoptexdefinition
>>
>
> \starttexdefinition stopBufTest
> \startnarrower[left,right]
> \startparagraph
> \dontleavehmode\llap{? }%
> \blank[overlay]
> \inlinebuffer[TestBuffer]
> \stopparagraph
> \stopnarrower
> \egroup
> \stoptexdefinition
>
>
> Wolfgang
Thank you, Wolfgang. That does it. Note that the % escaping the line end
is not needed ( although it might be needed outside a
\starttexdefinition environment) – the following works as well:
\starttexdefinition stopBufTest
\startnarrower[left,right]
\startparagraph
\dontleavehmode{\llap{? }}
\blank[overlay]
\inlinebuffer[TestBuffer]
\stopparagraph
\stopnarrower
\egroup
\stoptexdefinition
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 3831 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-13 22:43 ` Rik Kabel
@ 2018-08-14 14:46 ` Rik Kabel
2018-08-15 3:31 ` Aditya Mahajan
0 siblings, 1 reply; 20+ messages in thread
From: Rik Kabel @ 2018-08-14 14:46 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 2460 bytes --]
On 8/13/2018 18:43, Rik Kabel wrote:
> On 8/13/2018 15:52, Wolfgang Schuster wrote:
>>
>>
>> Rik Kabel schrieb am 13.08.18 um 20:27:
>>> On 8/13/2018 13:46, Wolfgang Schuster wrote:
>>>>
>>>> \starttext
>>>>
>>>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>>>
>>>> \input knuth
>>>>
>>>> \startnarrower
>>>>
>>>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>>>
>>>> \input knuth
>>>>
>>>> \stopnarrower
>>>>
>>>> \stoptext
>>>>
>>>> Wolfgang
>>>
>>> I am applying it incorrectly, or it does not work with the buffers
>>> created by \grabbufferdata:
>>>
>>> \setupwhitespace[none]
>>> \setupindenting[none]
>>> \starttexdefinition unexpanded startBufTest
>>> \bgroup
>>> \dosingleempty\dostartBufTest
>>> \stoptexdefinition
>>> \starttexdefinition dostartBufTest [#SETUPS]
>>> \getrawparameters[BufTest][xx=yy,#SETUPS]
>>> \grabbufferdata[TestBuffer][startBufTest][stopBufTest]
>>> \stoptexdefinition
>>> \starttexdefinition stopBufTest
>>> \startnarrower[left,right]
>>> \startparagraph
>>> \BeforePar{\dontleavehmode\llap{? }}\GotoPar
>>> \inlinebuffer[TestBuffer]
>>> \stopparagraph
>>> \stopnarrower
>>> \egroup
>>> \stoptexdefinition
>>>
>>
>> \starttexdefinition stopBufTest
>> \startnarrower[left,right]
>> \startparagraph
>> \dontleavehmode\llap{? }%
>> \blank[overlay]
>> \inlinebuffer[TestBuffer]
>> \stopparagraph
>> \stopnarrower
>> \egroup
>> \stoptexdefinition
>>
>>
>> Wolfgang
>
> Thank you, Wolfgang. That does it. Note that the % escaping the line
> end is not needed ( although it might be needed outside a
> \starttexdefinition environment) – the following works as well:
>
>
> \starttexdefinition stopBufTest
>
> \startnarrower[left,right]
>
> \startparagraph
>
> \dontleavehmode{\llap{? }}
>
> \blank[overlay]
>
> \inlinebuffer[TestBuffer]
>
> \stopparagraph
>
> \stopnarrower
>
> \egroup
>
> \stoptexdefinition
>
>
Alas, this is not yet a workable solution. It does not work with a
layout of grid=tolerant, which I am currently using (although it does
work with some other grid settings). For now I will just add empty [] to
the startBufTest invocations.
I really think, though, that a buffers.strip function would be the way
to go, instead of futzing after the damage is done.
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 4743 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-14 14:46 ` Rik Kabel
@ 2018-08-15 3:31 ` Aditya Mahajan
2018-08-15 7:07 ` Hans Hagen
0 siblings, 1 reply; 20+ messages in thread
From: Aditya Mahajan @ 2018-08-15 3:31 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Tue, 14 Aug 2018, Rik Kabel wrote:
> I really think, though, that a buffers.strip function would be the way to go,
> instead of futzing after the damage is done.
In lua, buffers.getcontent('name') gives the contents of the buffer
labelled 'name'. You can post-process this in whatever way you want. For
example, you could write a lua function userdata.strip that strips the
leading and ending black spaces from a string, and then call
context(userdata.strip(buffers.getcontent('name)))
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-15 3:31 ` Aditya Mahajan
@ 2018-08-15 7:07 ` Hans Hagen
2018-08-15 21:46 ` Rik Kabel
0 siblings, 1 reply; 20+ messages in thread
From: Hans Hagen @ 2018-08-15 7:07 UTC (permalink / raw)
To: mailing list for ConTeXt users, Aditya Mahajan
On 8/15/2018 5:31 AM, Aditya Mahajan wrote:
> On Tue, 14 Aug 2018, Rik Kabel wrote:
>
>> I really think, though, that a buffers.strip function would be the way
>> to go, instead of futzing after the damage is done.
>
> In lua, buffers.getcontent('name') gives the contents of the buffer
> labelled 'name'. You can post-process this in whatever way you want. For
> example, you could write a lua function userdata.strip that strips the
> leading and ending black spaces from a string, and then call
>
> context(userdata.strip(buffers.getcontent('name)))
local s = [[
foo
bar
bar
]]
print(string.fullstrip(s))
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-15 7:07 ` Hans Hagen
@ 2018-08-15 21:46 ` Rik Kabel
2018-08-16 14:55 ` Aditya Mahajan
0 siblings, 1 reply; 20+ messages in thread
From: Rik Kabel @ 2018-08-15 21:46 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
[-- Attachment #1.1: Type: text/plain, Size: 1561 bytes --]
On 8/15/2018 03:07, Hans Hagen wrote:
> On 8/15/2018 5:31 AM, Aditya Mahajan wrote:
>> On Tue, 14 Aug 2018, Rik Kabel wrote:
>>
>>> I really think, though, that a buffers.strip function would be the
>>> way to go, instead of futzing after the damage is done.
>>
>> In lua, buffers.getcontent('name') gives the contents of the buffer
>> labelled 'name'. You can post-process this in whatever way you want.
>> For example, you could write a lua function userdata.strip that
>> strips the leading and ending black spaces from a string, and then call
>>
>> context(userdata.strip(buffers.getcontent('name)))
> local s = [[
>
> foo
>
> bar
>
>
> bar
>
> ]]
>
> print(string.fullstrip(s))
>
>
So, it looks likethe following is closer to working for me in a simple
test harness, but not in my full-blown work:
\dontleavehmode{\llap{StripA~}}\ctxlua{context(utilities.strings.striplines(string.gsub(buffers.getcontent("TestBuffer"),"^\\relax",""),"prune"))}
(or similar with string.fullstrip).
However, it fails when the buffer starts with an unescaped left square
bracket. That is probably why the \relax is inserted, and I can see that
it is not a simple job to handle this. So, I will accept that I must
either append [] or get rid of the open layout for these cases.
I suspect that the issue in the larger project has to do with quoting
for the RE ("^\\relax") since compilation fails with:
%% \stopAttribution ...getcontent("Attribution"),"^\\
%% relax","")))}\stopparagrap...
Any pointers on such quoting would be appreciated.
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 2596 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-15 21:46 ` Rik Kabel
@ 2018-08-16 14:55 ` Aditya Mahajan
2018-08-16 20:02 ` Rik
0 siblings, 1 reply; 20+ messages in thread
From: Aditya Mahajan @ 2018-08-16 14:55 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, 15 Aug 2018, Rik Kabel wrote:
> On 8/15/2018 03:07, Hans Hagen wrote:
>> On 8/15/2018 5:31 AM, Aditya Mahajan wrote:
>>> On Tue, 14 Aug 2018, Rik Kabel wrote:
>>>
>>>> I really think, though, that a buffers.strip function would be the way to
>>>> go, instead of futzing after the damage is done.
>>>
>>> In lua, buffers.getcontent('name') gives the contents of the buffer
>>> labelled 'name'. You can post-process this in whatever way you want. For
>>> example, you could write a lua function userdata.strip that strips the
>>> leading and ending black spaces from a string, and then call
>>>
>>> context(userdata.strip(buffers.getcontent('name)))
>> local s = [[
>>
>> foo
>>
>> bar
>>
>>
>> bar
>>
>> ]]
>>
>> print(string.fullstrip(s))
>>
>>
> So, it looks likethe following is closer to working for me in a simple test
> harness, but not in my full-blown work:
>
> \dontleavehmode{\llap{StripA~}}\ctxlua{context(utilities.strings.striplines(string.gsub(buffers.getcontent("TestBuffer"),"^\\relax",""),"prune"))}
>
> (or similar with string.fullstrip).
>
> However, it fails when the buffer starts with an unescaped left square
> bracket. That is probably why the \relax is inserted, and I can see that it
> is not a simple job to handle this. So, I will accept that I must either
> append [] or get rid of the open layout for these cases.
>
> I suspect that the issue in the larger project has to do with quoting for the
> RE ("^\\relax") since compilation fails with:
>
> %% \stopAttribution ...getcontent("Attribution"),"^\\
> %% relax","")))}\stopparagrap...
>
> Any pointers on such quoting would be appreciated.
Please create a MWE.
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: How can I remove a blank leading line from a buffer
2018-08-16 14:55 ` Aditya Mahajan
@ 2018-08-16 20:02 ` Rik
0 siblings, 0 replies; 20+ messages in thread
From: Rik @ 2018-08-16 20:02 UTC (permalink / raw)
To: ntg-context
On 8/16/2018 10:55, Aditya Mahajan wrote:
> On Wed, 15 Aug 2018, Rik Kabel wrote:
>
>> I suspect that the issue in the larger project has to do with quoting
>> for the RE ("^\\relax") since compilation fails with:
>>
>> %% \stopAttribution ...getcontent("Attribution"),"^\\
>> %% relax","")))}\stopparagrap...
>>
>> Any pointers on such quoting would be appreciated.
>
> Please create a MWE.
>
> Aditya
I cannot at this point, and may well have misinterpreted what I saw.
--
Rik
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2018-08-16 20:02 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 3:18 How can I remove a blank leading line from a buffer Rik Kabel
2018-08-13 3:44 ` Aditya Mahajan
2018-08-13 3:46 ` Henri Menke
2018-08-13 7:02 ` Hans Hagen
2018-08-13 7:01 ` Hans Hagen
2018-08-13 14:28 ` Rik Kabel
2018-08-13 16:04 ` Wolfgang Schuster
2018-08-13 17:09 ` Rik Kabel
2018-08-13 17:46 ` Wolfgang Schuster
2018-08-13 18:27 ` Rik Kabel
2018-08-13 19:52 ` Wolfgang Schuster
2018-08-13 22:43 ` Rik Kabel
2018-08-14 14:46 ` Rik Kabel
2018-08-15 3:31 ` Aditya Mahajan
2018-08-15 7:07 ` Hans Hagen
2018-08-15 21:46 ` Rik Kabel
2018-08-16 14:55 ` Aditya Mahajan
2018-08-16 20:02 ` Rik
2018-08-13 16:15 ` Rik Kabel
2018-08-13 17:51 ` Rik Kabel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).