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