core-con.mkiv /size: 33 Kb    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=core-con,
3
%D version=1997.26.08,
4
%D title=\CONTEXT\ Core Macros,
5
%D subtitle=Conversion,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}
{
ConTeXt
Core
Macros
/
Conversion
}
15 16
\registerctxluafile
{
core
-
con
}
{
}
17 18
% todo: iso date ranges (from/to)
19 20
\unprotect
21 22
\ifdefined
\currentlanguage
\else
\let
\currentlanguage
\empty
\fi
23
\ifdefined
\labeltext
\else
\let
\labeltext
\firstofoneargument
\fi
24 25
%D This module deals with all kind of conversions from numbers and dates. I
26
%D considered splitting this module in a support one and a core one, but to keep
27
%D things simple as well as preserve the overview, I decided against splitting.
28 29
\let
\spr
\firstofoneargument
% separator
30
\let
\stp
\firstofoneargument
% stopper
31 32
% needed for arab:
33 34
\unexpanded
\def
\isolateseparators
% even works with list separator overloading
35
{
\def
\spr
#
#
1
{
{
#
#
1
}
}
% % we can probably best mess around with zwj
36
\def
\stp
#
#
1
{
{
#
#
1
}
}
}
% and friends
37 38
%D \macros
39
%D {numbers}
40
%D
41
%D First we deal with the dummy conversion of numbers using the \TEX\ primitive
42
%D \type{\number}. The uppercase alternative is only there for compatibility with
43
%D the other conversion macros. We could do without \type{#1} but this way we get
44
%D rid of unwanted braces. For the savety we also define a non||sence uppercase
45
%D alternative.
46
%D
47
%D \showsetup{numbers}
48
%D
49
%D \starttyping
50
%D \def\numbers#1{\number#1}
51
%D \def\Numbers#1{\number#1}
52
%D \stoptyping
53
%D
54
%D Due to read ahead, as in \type{[\pagenumber\space]} the space will disappear,
55
%D unless we use:
56 57
\def
\numbers
#
1
{
\purenumber
{
#
1
}
}
58
\def
\Numbers
#
1
{
\purenumber
{
#
1
}
}
59 60
%D \macros
61
%D {romannumerals,Romannumerals}
62
%D
63
%D \TEX\ the program uses a rather tricky conversion from numbers to their roman
64
%D counterparts. This conversion could of course be programmed in \TEX\ itself, but
65
%D I guess Knuth found the programming trick worth presenting.
66
%D
67
%D \showsetup{romannumerals}
68
%D \showsetup{Romannumerals}
69 70
\def
\romannumerals
#
1
{
\clf_romannumerals
\numexpr
#
1
\relax
}
71
\def
\Romannumerals
#
1
{
\clf_Romannumerals
\numexpr
#
1
\relax
}
72 73
%D Arabic etc:
74 75
\def
\abjadnumerals
#
1
{
\clf_abjadnumerals
\numexpr
#
1
\relax
}
76
\def
\abjadnodotnumerals
#
1
{
\clf_abjadnodotnumerals
\numexpr
#
1
\relax
}
77
\def
\abjadnaivenumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
arabic
}
}
% okay?
78 79
\def
\hebrewnumerals
#
1
{
\clf_hebrewnumerals
\numexpr
#
1
\relax
}
80
\let
\yiddishnumerals
\hebrewnumerals
81 82
\def
\languagecharacters
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
\currentlanguage
}
}
% new
83
\def
\languageCharacters
#
1
{
\clf_Alphabetic
\numexpr
#
1
\relax
{
\currentlanguage
}
}
% new
84 85
\def
\alphabeticnumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
}
}
86
\def
\Alphabeticnumerals
#
1
{
\clf_Alphabetic
\numexpr
#
1
\relax
{
}
}
87 88
\def
\thainumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
thai
}
}
89
\def
\devanagarinumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
devanagari
}
}
90
\def
\gurmurkhinumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
gurmurkhi
}
}
91
\def
\gujaratinumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
gujarati
}
}
92
\def
\tibetannumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
tibetan
}
}
93
\def
\greeknumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
greek
}
}
94
\def
\Greeknumerals
#
1
{
\clf_Alphabetic
\numexpr
#
1
\relax
{
greek
}
}
95
\def
\arabicnumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
arabic
}
}
96
\def
\persiannumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
persian
}
}
97
\def
\arabicdecimals
#
1
{
\clf_decimals
\numexpr
#
1
\relax
{
arabic
}
}
98
\def
\persiandecimals
#
1
{
\clf_decimals
\numexpr
#
1
\relax
{
persian
}
}
99 100
\let
\arabicexnumerals
\persiannumerals
101 102
\def
\koreannumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
korean
}
}
103
\def
\koreannumeralsp
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
korean
-
parenthesis
}
}
104
\def
\koreannumeralsc
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
korean
-
circle
}
}
105 106
\let
\koreanparentnumerals
\koreannumeralsp
107
\let
\koreanparenthesisnumerals
\koreannumeralsp
108
\let
\koreancirclenumerals
\koreannumeralsc
109 110
\def
\chinesenumerals
#
1
{
\clf_chinesenumerals
\numexpr
#
1
\relax
{
normal
}
}
111
\def
\chinesecapnumerals
#
1
{
\clf_chinesenumerals
\numexpr
#
1
\relax
{
cap
}
}
112
\def
\chineseallnumerals
#
1
{
\clf_chinesenumerals
\numexpr
#
1
\relax
{
all
}
}
113 114
%D \macros
115
%D {character,Character}
116
%D
117
%D Converting a number into a character can of course only be done with numbers
118
%D less or equal to~26. At the cost of much more macros a faster conversion is
119
%D possible, using:
120
%D
121
%D \starttyping
122
%D \setvalue{char1}{a} \def\character#1{\getvalue{char#1}}
123
%D \stoptyping
124
%D
125
%D But we prefer a simpel \type{\case}.
126
%D
127
%D \showsetup{character}
128
%D \showsetup{Character}
129 130
\def
\unknowncharacter
{
-
}
% else in lists \relax
131 132
\def
\character
#
1
{
\clf_character
\numexpr
#
1
\relax
}
133
\def
\Character
#
1
{
\clf_Character
\numexpr
#
1
\relax
}
134 135
%D \macros
136
%D {characters,Characters}
137
%D
138
%D Converting large numbers is supported by the next two macros. This time we
139
%D just count on: $\cdots$~x, y, z, aa, ab, ac~$\cdots$.
140
%D
141
%D \showsetup{characters}
142
%D \showsetup{Characters}
143 144
\def
\characters
#
1
{
\clf_characters
\numexpr
#
1
\relax
}
145
\def
\Characters
#
1
{
\clf_Characters
\numexpr
#
1
\relax
}
146 147
%D \macros
148
%D {greeknumerals,Greeknumerals}
149
%D
150
%D Why should we only honour the romans, and not the greek?
151 152
% \let\greeknumerals\gobbleoneargument
153
% \let\Greeknumerals\gobbleoneargument
154 155
%D \macros
156
%D {oldstylenumerals,oldstyleromannumerals}
157
%D
158
%D These conversions are dedicated to Frans Goddijn.
159 160
\unexpanded
\def
\oldstylenumerals
#
1
%
161
{
\begingroup
162
\os
\number
#
1
%
163
\endgroup
}
164 165
\unexpanded
\def
\oldstyleromannumerals
#
1
% will become obsolete
166
{
\dontleavehmode
167
\hbox
\bgroup
168
\ss
\txx
169
\setbox
\scratchbox
\hbox
\s!spread
.
1
5
\emwidth
{
\hss
\uppercased
{
\romannumerals
{
#
1
}
}
\hss
}
%
170
\scratchwidth
\wd
\scratchbox
171
\scratchheight
\ht
\scratchbox
172
\scratchdimen
.
1
\exheight
173
\vrule
\s!width
\scratchwidth
\s!height
\dimexpr
\scratchheight
+
\scratchdimen
\relax
\s!depth
-
\dimexpr
\scratchheight
-
+
\scratchdimen
\relax
174
\hskip
-
\scratchwidth
175
\vrule
\s!width
\scratchwidth
\s!height
\scratchdimen
\s!depth
\scratchdimen
176
\hskip
-
\scratchwidth
177
\box
\scratchbox
178
\egroup
}
179 180
%D \macros
181
%D {protectconversion}
182
%D
183
%D The previous two commands are not robust enough to be passed to \type
184
%D {\write} en \type{\message}. That's why we introduce:
185 186
\unexpanded
\def
\protectconversion
187
{
\let
\doconvertcharacters
\firstofoneargument
}
188 189
%D \macros
190
%D {normaltime,normalyear,normalmonth,normalday}
191
%D
192
%D The last part of this module is dedicated to converting dates. Because we want to
193
%D use as meaningful commands as possible, and because \TEX\ already uses up some of
194
%D those, we save the original meanings.
195 196
% \savenormalmeaning\time
197
% \savenormalmeaning\year
198
% \savenormalmeaning\month
199
% \savenormalmeaning\day
200 201
%D \macros
202
%D {month,MONTH}
203
%D
204
%D Converting the month number into a month name is done using a case statement,
205
%D abstact values and the label mechanism. This way users can easily redefine a
206
%D label from for instance german into austrian.
207
%D
208
%D \starttyping
209
%D \setuplabeltext [de] [january=J\"anner]
210
%D \stoptyping
211
%D
212
%D Anyhow, the conversion looks like:
213 214
\unexpanded
\def
\monthlong
#
1
{
\clf_monthname
\numexpr
#
1
\relax
}
215
\unexpanded
\def
\monthshort
#
1
{
\clf_monthmnem
\numexpr
#
1
\relax
}
216
\unexpanded
\def
\daylong
#
1
{
\clf_dayname
\numexpr
#
1
\relax
}
217
\unexpanded
\def
\dayshort
#
1
{
\clf_daymnem
\numexpr
#
1
\relax
}
218 219
\let
\convertmonth
\monthlong
% for old times sake
220 221
%D We redefine the \TEX\ primitive \type{\month} as:
222
%D
223
%D \showsetup{month}
224
%D \showsetup{MONTH}
225 226
\pushoverloadmode
227 228
\let
\month
\monthlong
229 230
\popoverloadmode
231 232
\unexpanded
\def
\MONTH
#
1
{
\WORD
{
\clf_monthname
\numexpr
#
1
\relax
}
}
233
\unexpanded
\def
\MONTHLONG
#
1
{
\WORD
{
\clf_monthname
\numexpr
#
1
\relax
}
}
234
\unexpanded
\def
\MONTHSHORT
#
1
{
\WORD
{
\clf_monthmnem
\numexpr
#
1
\relax
}
}
235 236
%D We never explicitly needed this, but Tobias Burnus pointed out that it would be
237
%D handy to convert to the day of the week. In doing so, we have to calculate the
238
%D total number of days, taking leapyears into account. For those who are curious:
239
%D
240
%D \startitemize[packed]
241
%D \item years that can be divided by 4 are leapyears
242
%D \item exept years that can be divided by 100
243
%D \item unless years can be divided by 400
244
%D \stopitemize
245 246
%D \macros
247
%D {weekday,WEEKDAY}
248
%D
249
%D The first one is sort of redundant. It takes the day number argument.
250
%D
251
%D \showsetup{weekday}
252
%D \showsetup{WEEKDAY}
253 254
\unexpanded
\def
\weekday
#
1
{
\clf_dayname
\numexpr
#
1
\relax
}
255
\unexpanded
\def
\WEEKDAY
#
1
{
\WORD
{
\clf_dayname
\numexpr
#
1
\relax
}
}
256
\unexpanded
\def
\DAYLONG
#
1
{
\WORD
{
\clf_dayname
\numexpr
#
1
\relax
}
}
257
\unexpanded
\def
\DAYSHORT
#
1
{
\WORD
{
\clf_daymnem
\numexpr
#
1
\relax
}
}
258 259
%D \macros
260
%D {getdayoftheweek, dayoftheweek}
261 262
\newcount
\normalweekday
263 264
\def
\dayoftheweek
#
1
#
2
#
3
{
\clf_weekdayname
\numexpr
#
1
\relax
\numexpr
#
2
\relax
\numexpr
#
3
\relax
}
% name
265
\unexpanded
\def
\getdayoftheweek
#
1
#
2
#
3
{
\normalweekday
\clf_weekday
\numexpr
#
1
\relax
\numexpr
#
2
\relax
\numexpr
#
3
\relax
\relax
}
% number
266 267
%D Using this macro in
268
%D
269
%D \startbuffer
270
%D monday: \dayoftheweek {4} {5} {1992}
271
%D friday: \dayoftheweek {16} {6} {1995}
272
%D monday: \dayoftheweek {25} {8} {1997}
273
%D saturday: \dayoftheweek {30} {8} {1997}
274
%D tuesday: \dayoftheweek {2} {1} {1996}
275
%D tuesday: \dayoftheweek {7} {1} {1997}
276
%D tuesday: \dayoftheweek {13} {1} {1998}
277
%D friday: \dayoftheweek {1} {1} {2000}
278
%D \stopbuffer
279
%D
280
%D \typebuffer
281
%D
282
%D gives
283
%D
284
%D \startlines
285
%D \getbuffer
286
%D \stoplines
287
%D
288
%D The macro \type {\getdayoftheweek} can be used to calculate the number \type
289
%D {\normalweekday}.
290 291
%D \macros
292
%D {doifleapyearelse,
293
%D getdayspermonth}
294
%D
295
%D Sometimes we need to know if we're dealing with a leapyear, so here is a
296
%D testmacro:
297
%D
298
%D \starttyping
299
%D \doifleapyearelse{year}{yes}{no}
300
%D \stoptyping
301
%D
302
%D An example of its use can be seen in the macro
303
%D
304
%D \starttyping
305
%D \getdayspermonth{year}{month}
306
%D \stoptyping
307
%D
308
%D The number of days is available in the macro \type {\numberofdays}.
309 310
\def
\doifelseleapyear
#
1
% expandable check
311
{
\clf_doifelseleapyear
\numexpr
#
1
\relax
}
312 313
\let
\doifleapyearelse
\doifelseleapyear
314 315
\unexpanded
\def
\getdayspermonth
#
1
#
2
%
316
{
\edef
\numberofdays
{
\clf_nofdays
\numexpr
#
1
\relax
\numexpr
#
2
\relax
}
}
317 318
\def
\dayspermonth
#
1
#
2
%
319
{
\clf_nofdays
\numexpr
#
1
\relax
\numexpr
#
2
\relax
}
320 321
% \dayoftheweek{2006}{9}{15}
322
% \doifleapyearelse{2000}{OK}{NOT OK}
323
% \doifleapyearelse{2100}{NOT OK}{OK}
324
% \doifleapyearelse{2004}{OK}{NOT OK}
325
% \doifleapyearelse{2003}{NOT OK}{OK}
326
% \dayspermonth{2000}{2}
327
% [\the\normaltime=\the\time]
328 329
%D \macros
330
%D {currentdate, rawdate, date}
331
%D
332
%D We use these conversion macros in the date formatting macro:
333
%D
334
%D \showsetup{currentdate}
335
%D
336
%D This macro takes care of proper spacing and delivers for instance:
337
%D
338
%D \startbuffer
339
%D \currentdate[weekday,day,month,year]
340
%D \currentdate[WEEKDAY,day,MONTH,year]
341
%D \stopbuffer
342
%D
343
%D \startlines
344
%D \getbuffer
345
%D \stoplines
346
%D
347
%D depending of course on the keywords. Here we gave:
348
%D
349
%D \typebuffer
350
%D
351
%D If needed one can also add non||keywords, like in
352
%D
353
%D \startbuffer
354
%D \currentdate[dd,--,mm,--,yy]
355
%D \stopbuffer
356
%D
357
%D \typebuffer
358
%D
359
%D or typeset: \getbuffer.
360
%D
361
%D When no argument is passed, the current date is given as specified per
362
%D language (using \type{\installlanguage}).
363
%D
364
%D \showsetup{currentdate}
365
%D
366
%D \startbuffer
367
%D \date
368
%D \date[d=12,m=12,y=1998][weekday]
369
%D \date[d=12,m=12,y=1998]
370
%D \stopbuffer
371
%D
372
%D We can also typeset arbitrary dates, using the previous
373
%D command.
374
%D
375
%D \typebuffer
376
%D
377
%D The date is specified by one character keys. When no date is given, we get the
378
%D current date.
379
%D
380
%D \startlines
381
%D \getbuffer
382
%D \stoplines
383 384
%D \starttabulate[|l|l|]
385
%D \HL
386
%D \NC year \NC (\currentdate[year]) \NC\NR
387
%D \NC yy \NC (\currentdate[yy]) \NC\NR
388
%D \NC y \NC (\currentdate[y]) \NC\NR
389
%D \NC Y \NC (\currentdate[Y]) \NC\NR
390
%D \HL
391
%D \NC month \NC (\currentdate[month]) \NC\NR
392
%D \NC mm \NC (\currentdate[mm]) \NC\NR
393
%D \NC m \NC (\currentdate[m]) \NC\NR
394
%D \NC M \NC (\currentdate[M]) \NC\NR
395
%D \HL
396
%D \NC day \NC (\currentdate[day]) \NC\NR
397
%D \NC dd \NC (\currentdate[dd]) \NC\NR
398
%D \NC d \NC (\currentdate[d]) \NC\NR
399
%D \NC D \NC (\currentdate[D]) \NC\NR
400
%D \HL
401
%D \NC weekday \NC (\currentdate[weekday]) \NC\NR
402
%D \NC w \NC (\currentdate[w]) \NC\NR
403
%D \NC W \NC (\currentdate[W]) \NC\NR
404
%D \HL
405
%D \NC referral \NC (\currentdate[referral]) \NC\NR
406
%D \HL
407
%D \NC day:mnem \NC (\currentdate[day:mnem]) \NC\NR
408
%D \NC dd:mnem \NC (\currentdate[dd:mnem]) \NC\NR
409
%D \NC d:mnem \NC (\currentdate[d:mnem]) \NC\NR
410
%D \NC D:mnem \NC (\currentdate[D:mnem]) \NC\NR
411
%D \HL
412
%D \stoptabulate
413
%D
414
%D \startbuffer
415
%D (\currentdate[D,.,M,.,Y])
416
%D (\currentdate[day,month,year])
417
%D (\currentdate[day,+,month,+,year])
418
%D \stopbuffer
419
%D
420
%D \typebuffer \getbuffer
421
%D
422
%D Some indirectness and abstraction:
423
%D
424
%D \starttyping
425
%D \definedate[crap][year]
426
%D \currentdate[crap]
427
%D \stoptyping
428 429
\installcorenamespace
{
date
}
430 431
\unexpanded
\def
\definedate
432
{
\dodoubleargument
\syst_converters_define_date
}
433 434
\def
\syst_converters_define_date
[
#
1
]
[
#
2
]
%
435
{
\setvalue
{
\??date
#
1
}
{
#
2
}
}
436 437
\def
\syst_converters_check_date_specification
#
1
%
438
{
\ifcsname
\??date
#
1
\endcsname
439
\edef
#
1
{
\lastnamedcs
}
%
440
\fi
}
441 442
\newtoks
\everycurrentdate
443 444
\unexpanded
\def
\currentdate
445
{
\dosingleempty
\syst_converters_current_date
}
446 447
\def
\syst_converters_current_date
[
#
1
]
%
448
{
\dontleavehmode
449
\begingroup
450
\the
\everycurrentdate
451
\edef
\forceddatespecification
{
#
1
}
%
452
\syst_converters_check_date_specification
\forceddatespecification
453
\syst_converters_check_date_specification
\currentdatespecification
454
\clf_currentdate
455
{
\forceddatespecification
}
{
\currentdatespecification
}
{
\labellanguage
}
%
456
\normalyear
\normalmonth
\normalday
457
\endgroup
}
458 459
\unexpanded
\def
\date
460
{
\dodoubleempty
\syst_converters_date
}
461 462
\def
\syst_converters_date
[
#
1
]
[
#
2
]
% sets the date !
463
{
\dontleavehmode
464
\iffirstargument
465
\begingroup
466
\letdummyparameter
\c!d
\normalday
467
\letdummyparameter
\c!m
\normalmonth
468
\letdummyparameter
\c!y
\normalyear
469
\getdummyparameters
[
#
1
]
%
470
\edef
\p_d
{
\directdummyparameter
\c!d
}
%
471
\edef
\p_m
{
\directdummyparameter
\c!m
}
%
472
\edef
\p_y
{
\directdummyparameter
\c!y
}
%
473
\normalexpanded
474
{
\endgroup
475
\ifx
\p_d
\empty
\else
\normalday
\number
\directdummyparameter
\c!d
\relax
\fi
476
\ifx
\p_m
\empty
\else
\normalmonth
\number
\directdummyparameter
\c!m
\relax
\fi
477
\ifx
\p_y
\empty
\else
\normalyear
\number
\directdummyparameter
\c!y
\relax
\fi
}
%
478
\fi
479
\begingroup
480
\the
\everycurrentdate
481
\edef
\forceddatespecification
{
#
2
}
%
482
\syst_converters_check_date_specification
\forceddatespecification
483
\syst_converters_check_date_specification
\currentdatespecification
484
\clf_currentdate
485
{
\forceddatespecification
}
{
\currentdatespecification
}
{
\labellanguage
}
%
486
\normalyear
\normalmonth
\normalday
487
\endgroup
}
488 489
\def
\rawdate
[
#
1
]
% expandable and no labels
490
{
\clf_currentdate
491
{
#
1
}
{
\currentdatespecification
}
{
}
%
492
\normalyear
\normalmonth
\normalday
}
493 494
%D \macros
495
%D {currenttime}
496
%D
497
%D The currenttime is actually the jobtime. You can specify a pattern similar
498
%D to the previous date macro using the keys \type {h}, \type {m} and a separator.
499 500
\unexpanded
\def
\calculatecurrenttime
501
{
\edef
\currenthour
{
\clf_hour
}
%
502
\edef
\currentminute
{
\clf_minute
}
%
503
\edef
\currentsecond
{
\clf_second
}
}
504 505
\let
\currenthour
\!!plusone
506
\let
\currentminute
\!!plusone
507
\let
\currentsecond
\!!plusone
508 509
% \def\currenttimespecification{h,:,m}
510 511
\unexpanded
\def
\currenttime
512
{
\doifelsenextoptional
\syst_converters_current_time_yes
\syst_converters_current_time_nop
}
513 514
\unexpanded
\def
\syst_converters_current_time_yes
[
#
1
]
%
515
{
\calculatecurrenttime
516
\processallactionsinset
[
#
1
]
[
h
=
>
\currenthour
,
m
=
>
\currentminute
,
\s!unknown
=
>
\commalistelement
]
}
517 518
\unexpanded
\def
\syst_converters_current_time_nop
519
{
\normalexpanded
{
\syst_converters_current_time_yes
[
\currenttimespecification
]
}
}
520 521
%D Because we're dealing with dates, we also introduce a few day loops:
522
%D
523
%D \starttyping
524
%D \processmonth{year}{month}{command}
525
%D \processyear{year}{command}{before}{after}
526
%D \stoptyping
527
%D
528
%D The counters \type {\normalyear}, \type {\normalmonth} and \type {\normalday}
529
%D can be used for for date manipulations.
530 531
\unexpanded
\def
\processmonth
#
1
#
2
#
3
% year month command
532
{
\begingroup
533
\getdayspermonth
{
#
1
}
{
#
2
}
%
534
\dostepwiserecurse
\plusone
\numberofdays
\plusone
535
{
\normalyear
#
1
\relax
536
\normalmonth
#
2
\relax
537
\normalday
\recurselevel
\relax
538
#
3
}
%
539
\endgroup
}
540 541
\def
\lastmonth
{
1
2
}
% can be set to e.g. 1 when testing
542 543
\unexpanded
\def
\processyear
#
1
#
2
#
3
#
4
% year command before after
544
{
\begingroup
545
\dorecurse
\lastmonth
546
{
\normalyear
#
1
\relax
547
\normalmonth
\recurselevel
\relax
548
#
3
\processmonth
\normalyear
\normalmonth
{
#
2
}
#
4
}
%
549
\endgroup
}
550 551
%D \macros
552
%D {defineconversion, convertnumber}
553
%D
554
%D Conversion involves the macros that we implemented earlier in this module.
555
%D
556
%D \showsetup{defineconversion}
557
%D \showsetup{convertnumber}
558
%D
559
%D We can feed this command with conversion macros as well as a set of conversion
560
%D symbols. Both need a bit different treatment.
561
%D
562
%D \starttyping
563
%D \defineconversion [roman] [\romannumerals]
564
%D \defineconversion [set 1] [$\star$,$\bullet$,$\ast$]
565
%D \stoptyping
566
%D
567
%D You can define a language dependent conversion with:
568
%D
569
%D \starttyping
570
%D \defineconversion [en] [whatever] [\something]
571
%D \stoptyping
572 573
\installcorenamespace
{
conversion
}
574
\installcorenamespace
{
conversionarguments
}
575
\installcorenamespace
{
conversionwords
}
576 577
%D It might be better to move more to \LUA\ as we also need conversion there and
578
%D doublicating logic doesn't make things cleaner. It means that all conversions
579
%D will get a language argument too. However, we permit definitions at the \TEX\ end
580
%D so we have to provide some hybrid method.
581 582
% checkedconversion(method,n,language)
583 584
\unexpanded
\def
\defineconversion
585
{
\dotripleempty
\syst_converters_define_conversion
}
586 587
\def
\syst_converters_define_conversion
[
#
1
]
[
#
2
]
[
#
3
]
% from now on global (maybe local again some day)
588
{
\ifthirdargument
589
\syst_converters_define_conversion_indeed
{
#
1
#
2
}
{
#
1
:
#
2
}
{
#
3
}
%
590
\else
591
\syst_converters_define_conversion_indeed
{
#
1
}
{
#
1
}
{
#
2
}
%
592
\fi
}
593 594
\def
\syst_converters_define_conversion_indeed
#
1
#
2
#
3
%
595
{
\doifelseinstring
{
,
}
{
\detokenize
{
#
3
}
}
596
{
\clf_defineconversion
{
#
2
}
{
\detokenize
{
#
3
}
}
% a set e.g. of symbols
597
\setgvalue
{
\??conversion
#
1
}
{
\syst_converters_checked_conversion
{
#
2
}
}
}
598
{
\setgvalue
{
\??conversion
#
1
}
{
#
3
}
}
}
599 600
\def
\syst_converters_checked_conversion
#
1
#
2
%
601
{
\clf_checkedconversion
{
#
1
}
\numexpr
#
2
\relax
}
602 603
%D If a conversion is just a font switch then we need to make sure that the number
604
%D is indeed ends up as number in the input, so we need to handle the second
605
%D argument.
606 607
\def
\convertnumber
#
1
#
2
% expandable
608
{
\csname
\??conversionarguments
609
\ifcsname
\??conversion
\currentlanguage
#
1
\endcsname
1
\else
610
\ifcsname
\??conversion
#
1
\endcsname
2
\else
611
3
\fi
\fi
612
\endcsname
{
#
1
}
{
\number
#
2
}
}
613 614
\unexpanded
\def
\uconvertnumber
% unexpandable
615
{
\convertnumber
}
616 617
\setvalue
{
\??conversionarguments
1
}
#
1
{
\csname
\??conversion
\currentlanguage
#
1
\endcsname
}
618
\setvalue
{
\??conversionarguments
2
}
#
1
{
\csname
\??conversion
#
1
\endcsname
}
619
\letvalue
{
\??conversionarguments
3
}
\syst_converters_checked_conversion
620 621
% we can also add a \ctxcommand{doifelseconversion("#1","\currentlanguage")} to check
622
% if we have definitions that are not matched at the lua end .. eventually we might do
623
% that when more shows up
624 625
\def
\doifelseconversiondefined
#
1
% expandable
626
{
\ifcsname
\??conversion
\currentlanguage
#
1
\endcsname
627
\expandafter
\firstoftwoarguments
628
\else
\ifcsname
\??conversion
#
1
\endcsname
629
\doubleexpandafter
\firstoftwoarguments
630
\else
631
\doubleexpandafter
\secondoftwoarguments
632
\fi
\fi
}
633 634
\def
\doifelseconversionnumber
#
1
#
2
% expandable
635
{
\ifnum
#
2
>
\numexpr
\clf_nofconversions
{
#
1
}
\relax
636
\expandafter
\secondoftwoarguments
637
\else
638
\expandafter
\firstoftwoarguments
639
\fi
}
640 641
\let
\doifconversiondefinedelse
\doifelseconversiondefined
642
\let
\doifconversionnumberelse
\doifelseconversionnumber
643 644
%D Handy.
645 646
\setvalue
{
\??conversionwords
\v!one
}
{
1
}
647
\setvalue
{
\??conversionwords
\v!two
}
{
2
}
648
\setvalue
{
\??conversionwords
\v!three
}
{
3
}
649
\setvalue
{
\??conversionwords
\v!four
}
{
4
}
650
\setvalue
{
\??conversionwords
\v!five
}
{
5
}
651 652
%def\wordtonumber#1#2{\ifcsname\??conversionwords#1\endcsname\csname\??conversionwords#1\endcsname\else#2\fi}
653
\def
\wordtonumber
#
1
#
2
{
\ifcsname
\??conversionwords
#
1
\endcsname
\lastnamedcs
\else
#
2
\fi
}
654 655
% \defineconversion[ctx][c,o,n,t,e,x,t]
656
%
657
% \doloop{\doifelseconversionnumber{ctx}{\recurselevel}{[\recurselevel]}{\exitloop}}
658 659
%D \macros
660
%D {ordinalnumber, highordinalstr, ordinalstr}
661
%D
662
%D Efficient general ordinal number converters are sometimes difficult to
663
%D implement. Fortunately dates never exceed the number~31.
664 665
\def
\highordinalstr
#
1
{
\high
{
\notsmallcapped
{
#
1
}
}
}
666
\def
\ordinalstr
#
1
{
\notsmallcapped
{
#
1
}
}
667
\def
\ordinalnumber
#
1
{
\clf_ordinal
\numexpr
#
1
\relax
{
\currentlanguage
}
}
668
\def
\Ordinalnumber
#
1
{
\Words
{
\clf_ordinal
\numexpr
#
1
\relax
{
\currentlanguage
}
}
}
669 670
\let
\verbosenumberconnector
\space
671 672
\def
\verbosenumber
#
1
{
\clf_verbose
\numexpr
#
1
\relax
{
\currentlanguage
}
{
\verbosenumberconnector
}
}
673
\def
\VerboseNumber
#
1
{
\Words
{
\clf_verbose
\numexpr
#
1
\relax
{
\currentlanguage
}
{
\verbosenumberconnector
}
}
}
674 675
%D As longs as symbols are linked to levels or numbers, we can also use the
676
%D conversion mechanism, but in for instance the itemization macros, we prefer
677
%D symbols because they can more easier be (partially) redefined. Symbols are
678
%D implemented in another module.
679 680
\def
\smallcappedromannumerals
#
1
{
\smallcapped
{
\romannumerals
{
#
1
}
}
}
681
\def
\smallcappedcharacters
#
1
{
\smallcapped
{
\characters
{
#
1
}
}
}
682 683
\defineconversion
[
]
[
\numbers
]
% the default conversion
684
\defineconversion
[
\v!empty
]
[
\gobbleoneargument
]
685
\defineconversion
[
\v!none
]
[
\numbers
]
686
\defineconversion
[
\s!default
]
[
\numbers
]
687 688
\defineconversion
[
month
]
[
\monthlong
]
689
\defineconversion
[
month
:
mnem
]
[
\monthshort
]
690 691
\defineconversion
[
\v!character
]
[
\character
]
692
\defineconversion
[
\v!Character
]
[
\Character
]
693 694
\defineconversion
[
\v!characters
]
[
\characters
]
695
\defineconversion
[
\v!Characters
]
[
\Characters
]
696 697
\defineconversion
[
a
]
[
\alphabeticnumerals
]
698
\defineconversion
[
A
]
[
\Alphabeticnumerals
]
699
\defineconversion
[
AK
]
[
\smallcappedcharacters
]
700
\defineconversion
[
KA
]
[
\smallcappedcharacters
]
701 702
\defineconversion
[
\v!alphabetic
]
[
\alphabeticnumerals
]
703
\defineconversion
[
\v!Alphabetic
]
[
\Alphabeticnumerals
]
704 705
\defineconversion
[
\v!number
]
[
\numbers
]
706
\defineconversion
[
\v!numbers
]
[
\numbers
]
707
\defineconversion
[
\v!Numbers
]
[
\Numbers
]
708
\defineconversion
[
\v!mediaeval
]
[
\mediaeval
]
709 710
\defineconversion
[
\v!word
]
[
\verbosenumber
]
711
\defineconversion
[
\v!words
]
[
\verbosenumber
]
712 713
\defineconversion
[
\v!Word
]
[
\VerboseNumber
]
714
\defineconversion
[
\v!Words
]
[
\VerboseNumber
]
715 716
\defineconversion
[
\v!ordinal
]
[
\ordinalnumber
]
717
\defineconversion
[
\v!Ordinal
]
[
\Ordinalnumber
]
718 719
\defineconversion
[
n
]
[
\numbers
]
720
\defineconversion
[
N
]
[
\Numbers
]
721
\defineconversion
[
m
]
[
\mediaeval
]
722
\defineconversion
[
o
]
[
\oldstylenumerals
]
723
\defineconversion
[
O
]
[
\oldstylenumerals
]
724
\defineconversion
[
or
]
[
\oldstyleromannumerals
]
725 726
\defineconversion
[
\v!romannumerals
]
[
\romannumerals
]
727
\defineconversion
[
\v!Romannumerals
]
[
\Romannumerals
]
728 729
\defineconversion
[
i
]
[
\romannumerals
]
730
\defineconversion
[
I
]
[
\Romannumerals
]
731
\defineconversion
[
r
]
[
\romannumerals
]
732
\defineconversion
[
R
]
[
\Romannumerals
]
733 734
\defineconversion
[
KR
]
[
\smallcappedromannumerals
]
735
\defineconversion
[
RK
]
[
\smallcappedromannumerals
]
736 737
\defineconversion
[
\v!greek
]
[
\greeknumerals
]
738
\defineconversion
[
\v!Greek
]
[
\Greeknumerals
]
739 740
\defineconversion
[
g
]
[
\greeknumerals
]
741
\defineconversion
[
G
]
[
\Greeknumerals
]
742 743
%defineconversion [ñ] [\spanishnumerals]
744
%defineconversion [Ñ] [\Spanishnumerals]
745 746
\defineconversion
[
abjadnumerals
]
[
\abjadnumerals
]
747
\defineconversion
[
abjadnodotnumerals
]
[
\abjadnodotnumerals
]
748
\defineconversion
[
abjadnaivenumerals
]
[
\abjadnaivenumerals
]
749 750
\defineconversion
[
hebrewnumerals
]
[
\hebrewnumerals
]
751
\defineconversion
[
yiddishnumerals
]
[
\yiddishnumerals
]
752 753
% users can do: \defineconversion [he] [\hebrewnumerals]
754
% users can do: \defineconversion [yi] [\hebrewnumerals]
755 756
\defineconversion
[
thainumerals
]
[
\thainumerals
]
757
\defineconversion
[
devanagarinumerals
]
[
\devanagarinumerals
]
758
\defineconversion
[
gurmurkhinumerals
]
[
\gurmurkhinumerals
]
759
\defineconversion
[
gujaratinumerals
]
[
\gujaratinumerals
]
760
\defineconversion
[
tibetannumerals
]
[
\tibetannumerals
]
761
\defineconversion
[
greeknumerals
]
[
\greeknumerals
]
762
\defineconversion
[
Greeknumerals
]
[
\Greeknumerals
]
763
\defineconversion
[
arabicnumerals
]
[
\arabicnumerals
]
764
\defineconversion
[
persiannumerals
]
[
\persiannumerals
]
765
\defineconversion
[
arabicexnumerals
]
[
\arabicexnumerals
]
766
\defineconversion
[
arabicdecimals
]
[
\arabicdecimals
]
767
\defineconversion
[
persiandecimals
]
[
\persiandecimals
]
768 769
\defineconversion
[
koreannumerals
]
[
\koreannumerals
]
770
\defineconversion
[
koreanparennumerals
]
[
\koreanparenthesisnumerals
]
% for old times sake (for a while)
771
\defineconversion
[
koreanparenthesisnumerals
]
772
[
\koreanparenthesisnumerals
]
773
\defineconversion
[
koreancirclenumerals
]
[
\koreancirclenumerals
]
774 775
\defineconversion
[
kr
]
[
\koreannumerals
]
776
\defineconversion
[
kr
-
p
]
[
\koreanparentnumerals
]
777
\defineconversion
[
kr
-
c
]
[
\koreancirclenumerals
]
778 779
\defineconversion
[
chinesenumerals
]
[
\chinesenumerals
]
780
\defineconversion
[
chinesecapnumerals
]
[
\chinesecapnumerals
]
781
\defineconversion
[
chineseallnumerals
]
[
\chineseallnumerals
]
782 783
\defineconversion
[
cn
]
[
\chinesenumerals
]
784
\defineconversion
[
cn
-
c
]
[
\chinesecapnumerals
]
785
\defineconversion
[
cn
-
a
]
[
\chineseallnumerals
]
786 787
%D Moved from lang-def.mkiv:
788
%D
789
%D Define these as the general character enumeration when language is Slovenian. If
790
%D you feel uncomfortable with this, mail Mojca, since she promised to to take the
791
%D heat. Pablo was next to request this. We changed characters to numerals for this
792
%D feature. We do need these definitions for mechanisms like itemize that check
793
%D for converters.
794 795
\def
\sloveniannumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
sl
}
}
796
\def
\slovenianNumerals
#
1
{
\clf_Alphabetic
\numexpr
#
1
\relax
{
sl
}
}
797 798
\def
\spanishnumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
es
}
}
799
\def
\spanishNumerals
#
1
{
\clf_Alphabetic
\numexpr
#
1
\relax
{
es
}
}
800 801
\def
\russiannumerals
#
1
{
\clf_alphabetic
\numexpr
#
1
\relax
{
ru
}
}
802
\def
\russianNumerals
#
1
{
\clf_Alphabetic
\numexpr
#
1
\relax
{
ru
}
}
803 804
%defineconversion [\s!sl] [character] [\sloveniannumerals]
805
%defineconversion [\s!sl] [Character] [\slovenianNumerals]
806
%defineconversion [\s!sl] [characters] [\sloveniannumerals]
807
%defineconversion [\s!sl] [Characters] [\slovenianNumerals]
808 809
\defineconversion
[
\s!sl
]
[
alphabetic
]
[
\sloveniannumerals
]
810
\defineconversion
[
\s!sl
]
[
Alphabetic
]
[
\slovenianNumerals
]
811 812
\defineconversion
[
\s!sl
]
[
a
]
[
\sloveniannumerals
]
813
\defineconversion
[
\s!sl
]
[
A
]
[
\slovenianNumerals
]
814
\defineconversion
[
\s!sl
]
[
AK
]
[
\smallcapped
\sloveniannumerals
]
815
\defineconversion
[
\s!sl
]
[
KA
]
[
\smallcapped
\sloveniannumerals
]
816 817
%defineconversion [\s!es] [character] [\spanishnumerals]
818
%defineconversion [\s!es] [Character] [\spanishNumerals]
819
%defineconversion [\s!es] [characters] [\spanishnumerals]
820
%defineconversion [\s!es] [Characters] [\spanishNumerals]
821 822
\defineconversion
[
\s!es
]
[
alphabetic
]
[
\spanishnumerals
]
823
\defineconversion
[
\s!es
]
[
Alphabetic
]
[
\spanishNumerals
]
824 825
\defineconversion
[
\s!es
]
[
a
]
[
\spanishnumerals
]
826
\defineconversion
[
\s!es
]
[
A
]
[
\spanishNumerals
]
827
\defineconversion
[
\s!es
]
[
AK
]
[
\smallcapped
\spanishnumerals
]
828
\defineconversion
[
\s!es
]
[
KA
]
[
\smallcapped
\spanishnumerals
]
829 830
%defineconversion [\s!ru] [character] [\russiannumerals]
831
%defineconversion [\s!ru] [Character] [\russianNumerals]
832
%defineconversion [\s!ru] [characters] [\russiannumerals]
833
%defineconversion [\s!ru] [Characters] [\russianNumerals]
834 835
\defineconversion
[
\s!ru
]
[
alphabetic
]
[
\russiannumerals
]
836
\defineconversion
[
\s!ru
]
[
Alphabetic
]
[
\russianNumerals
]
837 838
\defineconversion
[
\s!ru
]
[
a
]
[
\russiannumerals
]
839
\defineconversion
[
\s!ru
]
[
A
]
[
\russianNumerals
]
840
\defineconversion
[
\s!ru
]
[
AK
]
[
\smallcapped
\russiannumerals
]
841
\defineconversion
[
\s!ru
]
[
KA
]
[
\smallcapped
\russiannumerals
]
842 843
\defineconversion
[
sloveniannumerals
]
[
\sloveniannumerals
]
844
\defineconversion
[
slovenianNumerals
]
[
\slovenianNumerals
]
845 846
\defineconversion
[
spanishnumerals
]
[
\spanishnumerals
]
847
\defineconversion
[
spanishNumerals
]
[
\spanishNumerals
]
848 849
\defineconversion
[
russiannumerals
]
[
\russiannumerals
]
850
\defineconversion
[
russianNumerals
]
[
\russianNumerals
]
851 852
%D In case a font has no greek (WS):
853 854
\defineconversion
[
mathgreek
]
855
[
\m
{
α
}
,
\m
{
β
}
,
\m
{
γ
}
,
\m
{
δ
}
,
\m
{
ε
}
,
\m
{
ζ
}
,
856
\m
{
η
}
,
\m
{
θ
}
,
\m
{
ι
}
,
\m
{
κ
}
,
\m
{
λ
}
,
\m
{
μ
}
,
857
\m
{
ν
}
,
\m
{
ξ
}
,
\m
{
ο
}
,
\m
{
π
}
,
\m
{
ρ
}
,
\m
{
σ
}
,
858
\m
{
τ
}
,
\m
{
υ
}
,
\m
{
φ
}
,
\m
{
χ
}
,
\m
{
ψ
}
,
\m
{
ω
}
]
859 860
%D Handy too (expanded!):
861 862
\def
\unihex
#
1
{
\clf_unihex
\numexpr
#
1
\relax
}
863 864
%D Symbol sets:
865 866
\ifdefined
\symbol
\else
\def
\symbol
[
#
1
]
{
#
1
}
\fi
% todo
867 868
% \defineconversion
869
% [set 0]
870
% [{\symbol[bullet]},
871
% {\symbol[dash]},
872
% {\symbol[star]},
873
% {\symbol[triangle]},
874
% {\symbol[circle]},
875
% {\symbol[medcircle]},
876
% {\symbol[bigcircle]},
877
% {\symbol[square]},
878
% {\symbol[checkmark]}]
879 880
% \defineconversion
881
% [set 1]
882
% [\mathematics{\star},
883
% \mathematics{\star\star},
884
% \mathematics{\star\star\star},
885
% \mathematics{\ddagger},
886
% \mathematics{\ddagger\ddagger},
887
% \mathematics{\ddagger\ddagger\ddagger},
888
% \mathematics{\ast},
889
% \mathematics{\ast\ast},
890
% \mathematics{\ast\ast\ast}]
891
%
892
% \defineconversion
893
% [set 2]
894
% [\mathematics{\ast},
895
% \mathematics{\dag},
896
% \mathematics{\ddag},
897
% \mathematics{\ast\ast},
898
% \mathematics{\dag\dag},
899
% \mathematics{\ddag\ddag},
900
% \mathematics{\ast\ast\ast},
901
% \mathematics{\dag\dag\dag},
902
% \mathematics{\ddag\ddag\ddag},
903
% \mathematics{\ast\ast\ast\ast},
904
% \mathematics{\dag\dag\dag\dag},
905
% \mathematics{\ddag\ddag\ddag\ddag}]
906
%
907
% \defineconversion
908
% [set 3]
909
% [\mathematics{\star},
910
% \mathematics{\star\star},
911
% \mathematics{\star\star\star},
912
% \mathematics{\ddagger},
913
% \mathematics{\ddagger\ddagger},
914
% \mathematics{\ddagger\ddagger\ddagger},
915
% \mathematics{\P},
916
% \mathematics{\P\P},
917
% \mathematics{\P\P\P},
918
% \mathematics{\S},
919
% \mathematics{\S\S},
920
% \mathematics{\S\S\S},
921
% \mathematics{\ast},
922
% \mathematics{\ast\ast},
923
% \mathematics{\ast\ast\ast}]
924 925
\defineconversion
926
[
set
0
]
927
[
\symbol
{
bullet
}
,
928
\symbol
{
dash
}
,
929
\symbol
{
star
}
,
930
\symbol
{
triangle
}
,
931
\symbol
{
circle
}
,
932
\symbol
{
medcircle
}
,
933
\symbol
{
bigcircle
}
,
934
\symbol
{
square
}
,
935
\symbol
{
checkmark
}
]
936 937
\defineconversion
938
[
set
1
]
939
[
\textormathchars
{
}
,
940
\textormathchars
{
⋆⋆
}
,
941
\textormathchars
{
⋆⋆⋆
}
,
942
\textormathchars
{
}
,
943
\textormathchars
{
‡‡
}
,
944
\textormathchars
{
‡‡‡
}
,
945
\textormathchars
{
}
,
946
\textormathchars
{
∗∗
}
,
947
\textormathchars
{
∗∗∗
}
]
948 949
\defineconversion
950
[
set
2
]
951
[
\textormathchars
{
}
,
952
\textormathchars
{
}
,
953
\textormathchars
{
}
,
954
\textormathchars
{
∗∗
}
,
955
\textormathchars
{
††
}
,
956
\textormathchars
{
‡‡
}
,
957
\textormathchars
{
∗∗∗
}
,
958
\textormathchars
{
†††
}
,
959
\textormathchars
{
‡‡‡
}
,
960
\textormathchars
{
∗∗∗∗
}
,
961
\textormathchars
{
††††
}
,
962
\textormathchars
{
‡‡‡‡
}
]
963 964
\defineconversion
965
[
set
3
]
966
[
\textormathchars
{
}
,
967
\textormathchars
{
⋆⋆
}
,
968
\textormathchars
{
⋆⋆⋆
}
,
969
\textormathchars
{
}
,
970
\textormathchars
{
‡‡
}
,
971
\textormathchars
{
‡‡‡
}
,
972
\textormathchars
{
}
,
973
\textormathchars
{
¶¶
}
,
974
\textormathchars
{
¶¶¶
}
,
975
\textormathchars
{
§
}
,
976
\textormathchars
{
§§
}
,
977
\textormathchars
{
§§§
}
,
978
\textormathchars
{
}
,
979
\textormathchars
{
∗∗
}
,
980
\textormathchars
{
∗∗∗
}
]
981 982
%D Iteration of suggestion by WS on mailinglist 2010.12.22:
983
%D
984
%D \starttyping
985
%D \setupfloatsplitting[conversion=continued]
986
%D \stoptyping
987 988
\unexpanded
\def
\continuednumber
#
1
%
989
{
\labeltext
{
\ifcase
#
1
\or
\else
\v!continued
\fi
}
}
990 991
\defineconversion
992
[
\v!continued
]
993
[
\continuednumber
]
994 995
%D Taken from x-asciimath (see digits-001.tex for an example):
996 997
\let
\spaceddigitsmethod
\empty
% alternative methods : 1 default, 2 and 3 only when > 4
998
\let
\spaceddigitssymbol
\empty
% extra splitter symbol : {,}
999
\let
\spaceddigitsseparator
\empty
% separator symbol : {\Uchar{"2008}}
1000 1001
\unexpanded
\def
\spaceddigits
#
1
%
1002
{
\clf_spaceddigits
1003
method
{
\spaceddigitsmethod
}
%
1004
symbol
{
\spaceddigitssymbol
}
%
1005
separator
{
\spaceddigitsseparator
}
%
1006
data
{
#
1
}
%
1007
\relax
}
1008 1009
%D For those who sart counting at zero:
1010
%D
1011
%D \starttyping
1012
%D \defineconversionset [zero] [n,zero] [n]
1013
%D
1014
%D \setuphead [sectionconversionset=zero]
1015
%D
1016
%D \starttext
1017
%D \startchapter [title=Introduction]
1018
%D \startsection [title=First topic] \stopsection
1019
%D \startsection [title=Second topic] \stopsection
1020
%D \stopchapter
1021
%D \stoptext
1022
%D \stoptyping
1023 1024
\def
\zeronumberconversion
#
1
{
\number
\numexpr
#
1
-
\plusone
\relax
}
1025 1026
\defineconversion
[
zero
]
[
\zeronumberconversion
]
1027 1028
\protect
\endinput
1029