ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* A feq questions about eating spaces in macros
@ 2006-01-22 17:04 Radhelorn
  2006-01-23 10:50 ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Radhelorn @ 2006-01-22 17:04 UTC (permalink / raw)


Hello!

I have a few questions about ignoring unnecessary spaces and blank 
lines. The following example illustrates my problem. In the first 
start/stop pair text after \startcommand is not bold as it should be, in 
the second it is bold but blank line is before. I've tried to fix this 
with various manipulations with \noindent with moderate success.

Another problem is necessity to explicitly add % character before 
\stopcommand to ignore newline. How to do this inside macro with this 
combination of lines and sidebar?

Thanks in advance for any suggestions.

---------

\setuplines[before=,after=]

\def\startcommand{\dosingleargument\dostartcommand}

\def\dostartcommand[#1]%
   {\bgroup\defineshortcut[style=bold]#1\startlines\startsidebar}

\def\stopcommand{\stopsidebar\stoplines\egroup}

\starttext

\startcommand
<this must be bold>
\input knuth
<this is bold>%
\stopcommand

some text

\startcommand[arg]
<this is bold indeed but with a blank line before>
\input knuth
\stopcommand

\stoptext


-- 
Radhelorn <radhelorn@mail.ru>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A feq questions about eating spaces in macros
  2006-01-22 17:04 A feq questions about eating spaces in macros Radhelorn
@ 2006-01-23 10:50 ` Hans Hagen
  2006-01-24 13:45   ` A few " Radhelorn
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2006-01-23 10:50 UTC (permalink / raw)


Radhelorn wrote:

> Hello!
>
> I have a few questions about ignoring unnecessary spaces and blank 
> lines. The following example illustrates my problem. In the first 
> start/stop pair text after \startcommand is not bold as it should be, 
> in the second it is bold but blank line is before. I've tried to fix 
> this with various manipulations with \noindent with moderate success.
>
> Another problem is necessity to explicitly add % character before 
> \stopcommand to ignore newline. How to do this inside macro with this 
> combination of lines and sidebar?
>
> Thanks in advance for any suggestions.
>
> ---------
>
> \setuplines[before=,after=]
>
> \def\startcommand{\dosingleargument\dostartcommand}
>
> \def\dostartcommand[#1]%
>   {\bgroup\defineshortcut[style=bold]#1\startlines\startsidebar}
>
> \def\stopcommand{\stopsidebar\stoplines\egroup}
>
> \starttext
>
> \startcommand
> <this must be bold>
> \input knuth
> <this is bold>%
> \stopcommand
>
> some text
>
> \startcommand[arg]
> <this is bold indeed but with a blank line before>
> \input knuth
> \stopcommand
>
> \stoptext
>
>
\ignorespaces ....

... \removeunwantedspaces

Hans

-- 

-----------------------------------------------------------------
                                          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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A few questions about eating spaces in macros
  2006-01-23 10:50 ` Hans Hagen
@ 2006-01-24 13:45   ` Radhelorn
  2006-01-25 12:23     ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Radhelorn @ 2006-01-24 13:45 UTC (permalink / raw)


Hans Hagen wrote:
> Radhelorn wrote:
> 
>> Hello!
>>
>> I have a few questions about ignoring unnecessary spaces and blank 
>> lines. The following example illustrates my problem. In the first 
>> start/stop pair text after \startcommand is not bold as it should be, 
>> in the second it is bold but blank line is before. I've tried to fix 
>> this with various manipulations with \noindent with moderate success.
>>
>> Another problem is necessity to explicitly add % character before 
>> \stopcommand to ignore newline. How to do this inside macro with this 
>> combination of lines and sidebar?
>>
>> Thanks in advance for any suggestions.
>>
>> ---------
>>
>> \setuplines[before=,after=]
>>
>> \def\startcommand{\dosingleargument\dostartcommand}
>>
>> \def\dostartcommand[#1]%
>>   {\bgroup\defineshortcut[style=bold]#1\startlines\startsidebar}
>>
>> \def\stopcommand{\stopsidebar\stoplines\egroup}
>>
>> \starttext
>>
>> \startcommand
>> <this must be bold>
>> \input knuth
>> <this is bold>%
>> \stopcommand
>>
>> some text
>>
>> \startcommand[arg]
>> <this is bold indeed but with a blank line before>
>> \input knuth
>> \stopcommand
>>
>> \stoptext
>>
>>
> \ignorespaces ....
> 
> .... \removeunwantedspaces
> 
> Hans
> 

After some fiddling I've found that it is not spaces that interfere -- 
it's newlines. Is there a mechanism to ignore last newline as:

text text
\commandhere

to automatically become

text text\commandhere

and some mechanism to ignore future newline

\somecommand
text here

to become

\somecommand text here

??

Also I've found that for the very first example to work there is a need 
to manually add \leavevmode or something like this:

\startcommand
\leavevmode<this must be bold>

Maybe if there was an \ignorespaces after argument eating it would solve 
problems.



-- 
Radhelorn <radhelorn@mail.ru>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: A few questions about eating spaces in macros
  2006-01-24 13:45   ` A few " Radhelorn
@ 2006-01-25 12:23     ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2006-01-25 12:23 UTC (permalink / raw)


Radhelorn wrote:

>
>text text
>\commandhere
>  
>
\dontleavehmode\commandhere

-----------------------------------------------------------------
                                          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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-01-25 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-22 17:04 A feq questions about eating spaces in macros Radhelorn
2006-01-23 10:50 ` Hans Hagen
2006-01-24 13:45   ` A few " Radhelorn
2006-01-25 12:23     ` Hans Hagen

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).