1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
%D \module
%D [ file=toks-ini,
%D version=2007.03.03,
%D title=\CONTEXT\ Character Macros,
%D subtitle=Token Support (Initialization),
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{Token Support (initialization)}
\registerctxluafile{toks-ini}{1.001}
\unprotect
%D Handy for manuals \unknown
\def\starttokens [#1]{\ctxlua{collectors.install("#1", "stoptokens")}}
\let\stoptokens \relax
\def\flushtokens [#1]{\ctxlua{collectors.flush("#1")}}
\def\showtokens [#1]{\ctxlua{collectors.show("#1")}}
\def\testtokens [#1]{\ctxlua{collectors.with_words("#1")}}
\def\registertoken #1{\ctxlua{collectors.register("#1")}}
%D Inspired by a prototype by Taco for Thomas cum suis.
% \defineremapper[babelgreek]
%
% \remapcharacter[babelgreek][`a]{\alpha}
% \remapcharacter[babelgreek][`b]{\beta}
% \remapcharacter[babelgreek][`c]{\gamma}
% \remapcharacter[babelgreek][`d]{OEPS}
%
% \starttext
%
% [\startbabelgreek
% a b c some stuff here \blank[big] oeps b d
% \stopbabelgreek]
%
% [\babelgreek{some stuff here}]
%
% \stoptext
% incompatible with mkii ! ! ! ! so we need other names here
%
% \def\dograbuntil#1#2%
% {\long\def\next##1#1{#2##1}\next}
%
% \def\grabuntil#1%
% {\expandafter\dograbuntil\expandafter{\csname#1\endcsname}}
\def\dostartremapper#1%
{\ctxlua{collectors.install("#1", "\e!stop#1")}}
\def\dostopremapper#1%
{\ctxlua{collectors.handle("#1",function(str) return collectors.remapper.convert("#1",str) end, true)}}
\def\remaptokens#1%
{\ctxlua{collectors.handle("#1",function(str) return collectors.remapper.convert("#1",str) end)}}
\def\defineremapper[#1]%
{\setvalue{\e!start#1}{\dostartremapper{#1}}%
\setvalue{\e!stop #1}{\dostopremapper {#1}}%
\def\next##1{\setvalue{#1}####1{\getvalue{\e!start#1}####1##1}}%
\expandafter\next\csname\e!stop#1\endcsname}
\def\remapcharacter
{\dodoubleempty\doremapcharacter}
\def\doremapcharacter[#1][#2]#3%
{\ctxlua{collectors.install("store", "ctxlua")}#3%
\ctxlua{collectors.remapper.store("store","#1",\number#2)}}
\protect \endinput
|