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/
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
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 -----------------------------------------------------------------
On Fri, May 22, 2009 at 8:11 PM, Hans Hagen
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
luigi scarso wrote:
On Fri, May 22, 2009 at 8:11 PM, Hans Hagen
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 -----------------------------------------------------------------
On Mon, May 25, 2009 at 12:17 PM, Hans Hagen
luigi scarso wrote:
On Fri, May 22, 2009 at 8:11 PM, Hans Hagen
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
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/
On Mon, May 25, 2009 at 12:18 PM, Peter Münster
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
participants (4)
-
Hans Hagen
-
luigi scarso
-
Peter Münster
-
Wolfgang Schuster