ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* defineremapper as default (in style file)
@ 2009-05-22 17:47 Peter Münster
  2009-05-22 18:05 ` Wolfgang Schuster
  2009-05-22 18:11 ` Hans Hagen
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Münster @ 2009-05-22 17:47 UTC (permalink / raw)
  To: ConTeXt list

Hello,

I would like to activate a remapper in a style or module file. How could
this be done?

I tried this without success:

\defineremapper[filterItem]
\remapcharacter[filterItem][`•]{\item}
\appendtoks \startfilterItem \to \everystarttext
\prependtoks \stopfilterItem  \to \everystoptext

TIA for any hints!
Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: defineremapper as default (in style file)
  2009-05-22 17:47 defineremapper as default (in style file) Peter Münster
@ 2009-05-22 18:05 ` Wolfgang Schuster
  2009-05-22 18:11 ` Hans Hagen
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Schuster @ 2009-05-22 18:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 22.05.2009 um 19:47 schrieb Peter Münster:

> Hello,
>
> I would like to activate a remapper in a style or module file. How  
> could
> this be done?
>
> I tried this without success:
>
> \defineremapper[filterItem]
> \remapcharacter[filterItem][`•]{\item}
> \appendtoks \startfilterItem \to \everystarttext
> \prependtoks \stopfilterItem  \to \everystoptext

Why so complicated!

\catcode`•=\active
\def•{\item}

and of course use ConTeXt’s own commands for the above code.

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: defineremapper as default (in style file)
  2009-05-22 17:47 defineremapper as default (in style file) Peter Münster
  2009-05-22 18:05 ` Wolfgang Schuster
@ 2009-05-22 18:11 ` Hans Hagen
  2009-05-25 10:02   ` luigi scarso
  1 sibling, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2009-05-22 18:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Peter Münster wrote:
> Hello,
> 
> I would like to activate a remapper in a style or module file. How could
> this be done?
> 
> I tried this without success:
> 
> \defineremapper[filterItem]
> \remapcharacter[filterItem][`•]{\item}
> \appendtoks \startfilterItem \to \everystarttext
> \prependtoks \stopfilterItem  \to \everystoptext

kep in mind that the remapper is just a hack and will not be extended 
etc etc; i'm not going to handle interferences with other mechanisms

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
-----------------------------------------------------------------
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: defineremapper as default (in style file)
  2009-05-22 18:11 ` Hans Hagen
@ 2009-05-25 10:02   ` luigi scarso
  2009-05-25 10:17     ` Hans Hagen
  2009-05-25 10:18     ` Peter Münster
  0 siblings, 2 replies; 8+ messages in thread
From: luigi scarso @ 2009-05-25 10:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 920 bytes --]

On Fri, May 22, 2009 at 8:11 PM, Hans Hagen <pragma@wxs.nl> wrote:

> Peter Münster wrote:
>
>> Hello,
>>
>> I would like to activate a remapper in a style or module file. How could
>> this be done?
>>
>> I tried this without success:
>>
>> \defineremapper[filterItem]
>> \remapcharacter[filterItem][`•]{\item}
>> \appendtoks \startfilterItem \to \everystarttext
>> \prependtoks \stopfilterItem  \to \everystoptext
>>
>

>
> kep in mind that the remapper is just a hack and will not be extended etc
> etc; i'm not going to handle interferences with other mechanisms
>

> Hans
>


I think the point is this :
in some situations one find useful to convert things like • in macros like
\item .
Of course, it can be done with  preprocessing , or with some ad-hoc macros
in lua code , etc
So, apart \remapcharacter, are there  any other safe ways to "remap
character" ?


-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1719 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: defineremapper as default (in style file)
  2009-05-25 10:02   ` luigi scarso
@ 2009-05-25 10:17     ` Hans Hagen
  2009-05-25 10:23       ` luigi scarso
  2009-05-25 10:18     ` Peter Münster
  1 sibling, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2009-05-25 10:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

luigi scarso wrote:
> On Fri, May 22, 2009 at 8:11 PM, Hans Hagen <pragma@wxs.nl> wrote:
> 
>> Peter Münster wrote:
>>
>>> Hello,
>>>
>>> I would like to activate a remapper in a style or module file. How could
>>> this be done?
>>>
>>> I tried this without success:
>>>
>>> \defineremapper[filterItem]
>>> \remapcharacter[filterItem][`•]{\item}
>>> \appendtoks \startfilterItem \to \everystarttext
>>> \prependtoks \stopfilterItem  \to \everystoptext
>>>
> 
>> kep in mind that the remapper is just a hack and will not be extended etc
>> etc; i'm not going to handle interferences with other mechanisms
>>
> 
>> Hans
>>
> 
> 
> I think the point is this :
> in some situations one find useful to convert things like • in macros like
> \item .
> Of course, it can be done with  preprocessing , or with some ad-hoc macros
> in lua code , etc
> So, apart \remapcharacter, are there  any other safe ways to "remap
> character" ?

one solution mentioned was making that character active and then do an 
unexpanded def which makes it roundtrip safe;  of course we should leave 
characters like : untouched

the remapper works on all input and it might result in unwanted side 
effects .. imagine that someone defines symbol 1 as • and gets \item 
instead

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
-----------------------------------------------------------------
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: defineremapper as default (in style file)
  2009-05-25 10:02   ` luigi scarso
  2009-05-25 10:17     ` Hans Hagen
@ 2009-05-25 10:18     ` Peter Münster
  2009-05-25 10:24       ` luigi scarso
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Münster @ 2009-05-25 10:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 25 May 2009, luigi scarso wrote:

> I think the point is this :
> in some situations one find useful to convert things like • in macros like
> \item .
> Of course, it can be done with  preprocessing , or with some ad-hoc macros in
> lua code , etc
> So, apart \remapcharacter, are there  any other safe ways to "remap character"
> ?

Wolfgang mentioned the method with active character.
And there is also this one:

\startluacode
function my_replace(line)
	return line:gsub('• ', '\\item ')
end
callback.register('process_input_buffer', my_replace)
\stopluacode
\starttext
\startitemize
• bla
• bla
• bla
\stopitemize
\stoptext

I like the latter one, because it permits also replacing whole words and
much more. But you need to be careful, see also:
http://archive.contextgarden.net/message/20080404.200709.454e4740.en.html
;)

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: defineremapper as default (in style file)
  2009-05-25 10:17     ` Hans Hagen
@ 2009-05-25 10:23       ` luigi scarso
  0 siblings, 0 replies; 8+ messages in thread
From: luigi scarso @ 2009-05-25 10:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1678 bytes --]

On Mon, May 25, 2009 at 12:17 PM, Hans Hagen <pragma@wxs.nl> wrote:

> luigi scarso wrote:
>
>> On Fri, May 22, 2009 at 8:11 PM, Hans Hagen <pragma@wxs.nl> wrote:
>>
>>  Peter Münster wrote:
>>>
>>>  Hello,
>>>>
>>>> I would like to activate a remapper in a style or module file. How could
>>>> this be done?
>>>>
>>>> I tried this without success:
>>>>
>>>> \defineremapper[filterItem]
>>>> \remapcharacter[filterItem][`•]{\item}
>>>> \appendtoks \startfilterItem \to \everystarttext
>>>> \prependtoks \stopfilterItem  \to \everystoptext
>>>>
>>>>
>>  kep in mind that the remapper is just a hack and will not be extended etc
>>> etc; i'm not going to handle interferences with other mechanisms
>>>
>>>
>>  Hans
>>>
>>>
>>
>> I think the point is this :
>> in some situations one find useful to convert things like • in macros like
>> \item .
>> Of course, it can be done with  preprocessing , or with some ad-hoc macros
>> in lua code , etc
>> So, apart \remapcharacter, are there  any other safe ways to "remap
>> character" ?
>>
>
> one solution mentioned was making that character active and then do an
> unexpanded def which makes it roundtrip safe;  of course we should leave
> characters like : untouched
>

there was an article many years ago something like "Active characters -- No
thank you"


> the remapper works on all input and it might result in unwanted side
> effects .. imagine that someone defines symbol 1 as • and gets \item instead
>
this is true -- it's not a general solution it's a trick , it if you abuse
then....

>
>
> Hans
>

Maybe I'm not able to express what I mean .
-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 3208 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: defineremapper as default (in style file)
  2009-05-25 10:18     ` Peter Münster
@ 2009-05-25 10:24       ` luigi scarso
  0 siblings, 0 replies; 8+ messages in thread
From: luigi scarso @ 2009-05-25 10:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1070 bytes --]

On Mon, May 25, 2009 at 12:18 PM, Peter Münster <pmlists@free.fr> wrote:

> On Mon, 25 May 2009, luigi scarso wrote:
>
> > I think the point is this :
> > in some situations one find useful to convert things like • in macros
> like
> > \item .
> > Of course, it can be done with  preprocessing , or with some ad-hoc
> macros in
> > lua code , etc
> > So, apart \remapcharacter, are there  any other safe ways to "remap
> character"
> > ?
>
> Wolfgang mentioned the method with active character.
> And there is also this one:
>
> \startluacode
> function my_replace(line)
>        return line:gsub('• ', '\\item ')
> end
> callback.register('process_input_buffer', my_replace)
> \stopluacode
> \starttext
> \startitemize
> • bla
> • bla
> • bla
> \stopitemize
> \stoptext
>
> I like the latter one, because it permits also replacing whole words and
> much more. But you need to be careful, see also:
> http://archive.contextgarden.net/message/20080404.200709.454e4740.en.html
> ;)
>
>
This is what I mean .

-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1604 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2009-05-25 10:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-22 17:47 defineremapper as default (in style file) Peter Münster
2009-05-22 18:05 ` Wolfgang Schuster
2009-05-22 18:11 ` Hans Hagen
2009-05-25 10:02   ` luigi scarso
2009-05-25 10:17     ` Hans Hagen
2009-05-25 10:23       ` luigi scarso
2009-05-25 10:18     ` Peter Münster
2009-05-25 10:24       ` luigi scarso

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