blob: 425eae215f60734a985a74b1b6aae17a239caabf (
plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
%D \module
%D [ file=supp-pat,
%D version=2005.02.12,
%D title=\CONTEXT\ Support Macros,
%D subtitle=Patterns,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
%D We support:
%D
%D \starttyping
%D \patterns {
%D ...[namedglyphs]...
%D }
%D \stoptyping
%D
%D as well as:
%D
%D \starttyping
%D <patterns>
%D ...&namedglyphs;...
%D </patterns>
%D \stoptyping
%D
%D The \XML\ variant has very limited \XML\ parsing capabilities and
%D is meant as an experiment.
\ifx\writestatus\undefined \else
\writestatus{loading}{ConTeXt Support Macros / Patterns}
\fi
%D \CONTEXT:
\ifx\startmapping\undefined \else \ifx\startencoding\undefined \else
\def\fetchpatterntoken#1{\csname#1\endcsname}
\fi \fi
%D First we define the \ETEX\ variant. We cannot do that inside
%D the if statement because normal \TEX\ gets confused over the
%D csname test (which it does not see as if but it does see the
%D else's and fi's).
\def\etexfetchpatterntoken#1%
{\csname
\ifcsname @pattok@#1\endcsname
@pattok@#1%
\else\ifcsname#1\endcsname
#1%
\else
@pattok@default%
\fi\fi
\endcsname}
\ifx \fetchpatterntoken \undefined
\ifx \eTeXversion \undefined
\def\fetchpatterntoken#1%
{\csname
\expandafter\ifx\csname @pattok@#1\endcsname\relax
\expandafter\ifx\csname#1\endcsname\relax
@pattok@default%
\else
#1%
\fi
\else
@pattok@#1%
\fi
\endcsname}
\else
\let\fetchpatterntoken\etexfetchpatterntoken
\fi
\fi
\def\definepatterntoken #1 #2 %
{\expandafter\def\csname @pattok@#1\endcsname{#2}}
%D \TEX\ based:
\bgroup \catcode`\[=\active
\gdef\enablepatterntokens
{\catcode`\[=\active \let[\handlepatterntoken}
\egroup
\def\handlepatterntoken#1]%
{\fetchpatterntoken{#1}}
%D \XML\ based:
\bgroup \catcode`\<=\active \catcode`\&=\active
\gdef\enablepatternxml
{\catcode`\<=\active
\catcode`\&=\active
\let&\handlepatternentity
\let<\handlepatternxml}
\egroup
\def\handlepatternentity#1;%
{\fetchpatterntoken{#1}}
%D We use a very simple \XML\ parser, and we only trigger on the first
%D two characters of the tag name. Consider this feature a playground
%D (and a bit of a joke).
\def\handlepatternxml#1#2% we only distinguish the first two chars
{\csname @patxml@\ifcsname @patxml@#1#2\endcsname#1#2\else de\fi\endcsname}
\def\definepatternxml #1#2#3 #4%
{\expandafter\def\csname @patxml@#1#2\endcsname{#4}}
\def\fetchpatternxml#1#2>%
{\bgroup
\long\def\next##1>{\egroup}%
\catcode`\<=2 % \@@endgroup
\afterassignment\next
#1\bgroup}
\def\gobblepatternxml
{\bgroup
\catcode`\%=11
\dogobblepatternxml}
\long\def\dogobblepatternxml#1>%
{\egroup}
%D Here are the default definitions. We don't catch empty elements.
\definepatternxml patterns {\fetchpatternxml\patterns}
\definepatternxml hyphenations {\fetchpatternxml\hyphenation}
\definepatternxml pattern {\fetchpatternxml\patterns}
\definepatternxml hyphenation {\fetchpatternxml\hyphenation}
\definepatternxml default {\gobblepatternxml}
\definepatterntoken default x
\ifx\pattern \undefined \let\pattern \patterns \fi
\ifx\hyphenations\undefined \let\hyphenations\hyphenation \fi
%D An example of usage in another format than \CONTEXT:
%D
%D \starttyping
%D \bgroup
%D
%D \lccode"E4="E4 \definepatterntoken adiaeresis ^^e4
%D \lccode"F6="F6 \definepatterntoken odiaeresis ^^f6
%D \lccode"FC="FC \definepatterntoken ediaeresis ^^fc
%D \lccode"FF="FF \definepatterntoken ssharp ^^ff
%D
%D \enablepatterntokens
%D \enablepatternxml
%D
%D \input lang-de.pat
%D \input lang-de.hyp
%D
%D \egroup
%D \stoptyping
%D
%D This is a minimal example for EC encoding, and of course
%D a couple of more language related settings need to take
%D place (like uc mappings).
\endinput
|