ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* TeX: Macro definition
@ 2011-04-07  9:27 Procházka Lukáš Ing. - Pontex s. r. o.
  2011-04-07  9:45 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-04-07  9:27 UTC (permalink / raw)
  To: ConTeXt

Hello,

how to define a macro to take the new-line character as end-of-parameter?

The following macro:

\def\T#1\par{#1}

takes everything until \par (or empty line as it equals \par primitive) as #1, so the following is valid:

\T abc def\par
\T abc

\T def

(#1 becomes: "abc def", "abc" and "def".)

How to define the same macro to accept end-of-line as end-of-parameter?

I tried (although I'm aware this may not lead to the goal):

\def\T#1^^M{#1}

or

\def\T#1\crlf{#1}

to allow writing:

\T abc def
\T abc
\T def

So how to define the macro?

Thanks in advance.

Kind regards,

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

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


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

* Re: TeX: Macro definition
  2011-04-07  9:27 TeX: Macro definition Procházka Lukáš Ing. - Pontex s. r. o.
@ 2011-04-07  9:45 ` Wolfgang Schuster
  2011-04-07  9:55   ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2011-04-07  9:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 07.04.2011 um 11:27 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:

> Hello,
> 
> how to define a macro to take the new-line character as end-of-parameter?
> 
> The following macro:
> 
> \def\T#1\par{#1}
> 
> takes everything until \par (or empty line as it equals \par primitive) as #1, so the following is valid:
> 
> \T abc def\par
> \T abc
> 
> \T def
> 
> (#1 becomes: "abc def", "abc" and "def".)
> 
> How to define the same macro to accept end-of-line as end-of-parameter?
> 
> I tried (although I'm aware this may not lead to the goal):
> 
> \def\T#1^^M{#1}
> 
> or
> 
> \def\T#1\crlf{#1}
> 
> to allow writing:
> 
> \T abc def
> \T abc
> \T def
> 
> So how to define the macro?

\bgroup
\obeylines
\gdef\foo{\bgroup\obeylines\dofoo}%
\gdef\dofoo#1
  {\egroup%
   “#1”}%
\egroup

\starttext
<\foo some text
>
\stoptext

but don’t use it because this isn’t context style and we have
already enough exceptions with \DESCRIPTION and \item.

Wolfgang

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


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

* Re: TeX: Macro definition
  2011-04-07  9:45 ` Wolfgang Schuster
@ 2011-04-07  9:55   ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 0 replies; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-04-07  9:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thanks for the piece of code.

The macro is temporary - not systematic.

It should just help me to restyle some copy-pasted text from Word to .mkiv source.

This way, I'm just prefixing such lines with e.g. \foo, no extra job is necassary, just to create a valid body of the macro (\dofoo).

Lukas


On Thu, 07 Apr 2011 11:45:06 +0200, Wolfgang Schuster <schuster.wolfgang@googlemail.com> wrote:

>
> Am 07.04.2011 um 11:27 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:
>
>> Hello,
>>
>> how to define a macro to take the new-line character as end-of-parameter?
>>
>> The following macro:
>>
>> \def\T#1\par{#1}
>>
>> takes everything until \par (or empty line as it equals \par primitive) as #1, so the following is valid:
>>
>> \T abc def\par
>> \T abc
>>
>> \T def
>>
>> (#1 becomes: "abc def", "abc" and "def".)
>>
>> How to define the same macro to accept end-of-line as end-of-parameter?
>>
>> I tried (although I'm aware this may not lead to the goal):
>>
>> \def\T#1^^M{#1}
>>
>> or
>>
>> \def\T#1\crlf{#1}
>>
>> to allow writing:
>>
>> \T abc def
>> \T abc
>> \T def
>>
>> So how to define the macro?
>
> \bgroup
> \obeylines
> \gdef\foo{\bgroup\obeylines\dofoo}%
> \gdef\dofoo#1
>   {\egroup%
>    “#1”}%
> \egroup
>
> \starttext
> <\foo some text
>>
> \stoptext
>
> but don’t use it because this isn’t context style and we have
> already enough exceptions with \DESCRIPTION and \item.
>
> Wolfgang


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

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

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

end of thread, other threads:[~2011-04-07  9:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-07  9:27 TeX: Macro definition Procházka Lukáš Ing. - Pontex s. r. o.
2011-04-07  9:45 ` Wolfgang Schuster
2011-04-07  9:55   ` Procházka Lukáš Ing. - Pontex s. r. o.

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