diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-con.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-con.mkiv | 188 |
1 files changed, 90 insertions, 98 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-con.mkiv b/Master/texmf-dist/tex/context/base/core-con.mkiv index 241d4316595..7febdcf39f6 100644 --- a/Master/texmf-dist/tex/context/base/core-con.mkiv +++ b/Master/texmf-dist/tex/context/base/core-con.mkiv @@ -20,35 +20,27 @@ \ifdefined\currentlanguage \else \let\currentlanguage\empty \fi \ifdefined\labeltext \else \let\labeltext \firstofoneargument \fi -%D This module deals with all kind of conversions from numbers -%D and dates. I considered splitting this module in a support -%D one and a core one, but to keep things simple as well as -%D preserve the overview, I decided against splitting. +%D This module deals with all kind of conversions from numbers and dates. I +%D considered splitting this module in a support one and a core one, but to keep +%D things simple as well as preserve the overview, I decided against splitting. \let\spr\firstofoneargument % separator \let\stp\firstofoneargument % stopper -% cleaner, some day: -% -% \def\isolateseparators % etex only, even works with list separator overloading -% {\unexpanded\def\spr##1{{##1}}% -% \unexpanded\def\stp##1{{##1}}} - -% needed for arab : +% needed for arab: \unexpanded\def\isolateseparators % even works with list separator overloading - {\def\spr##1{{##1}}% - \def\stp##1{{##1}}} + {\def\spr##1{{##1}}% % we can probably best mess around with zwj + \def\stp##1{{##1}}} % and friends %D \macros %D {numbers} %D -%D First we deal with the dummy conversion of numbers using the -%D \TEX\ primitive \type{\number}. The uppercase alternative is -%D only there for compatibility with the other conversion -%D macros. We could do without \type{#1} but this way we get -%D rid of unwanted braces. For the savety we also define a -%D non||sence uppercase alternative. +%D First we deal with the dummy conversion of numbers using the \TEX\ primitive +%D \type{\number}. The uppercase alternative is only there for compatibility with +%D the other conversion macros. We could do without \type{#1} but this way we get +%D rid of unwanted braces. For the savety we also define a non||sence uppercase +%D alternative. %D %D \showsetup{numbers} %D @@ -57,8 +49,8 @@ %D \def\Numbers#1{\number#1} %D \stoptyping %D -%D Due to read ahead, as in \type{[\pagenumber\space]} the space will -%D disappear, unless we use: +%D Due to read ahead, as in \type{[\pagenumber\space]} the space will disappear, +%D unless we use: \def\numbers#1{\purenumber{#1}} \def\Numbers#1{\purenumber{#1}} @@ -66,10 +58,9 @@ %D \macros %D {romannumerals,Romannumerals} %D -%D \TEX\ the program uses a rather tricky conversion from -%D numbers to their roman counterparts. This conversion could -%D of course be programmed in \TEX\ itself, but I guess Knuth -%D found the programming trick worth presenting. +%D \TEX\ the program uses a rather tricky conversion from numbers to their roman +%D counterparts. This conversion could of course be programmed in \TEX\ itself, but +%D I guess Knuth found the programming trick worth presenting. %D %D \showsetup{romannumerals} %D \showsetup{Romannumerals} @@ -113,9 +104,9 @@ %D \macros %D {character,Character} %D -%D Converting a number into a character can of course only -%D be done with numbers less or equal to~26. At the cost of -%D much more macros a faster conversion is possible, using: +%D Converting a number into a character can of course only be done with numbers +%D less or equal to~26. At the cost of much more macros a faster conversion is +%D possible, using: %D %D \starttyping %D \setvalue{char1}{a} \def\character#1{\getvalue{char#1}} @@ -134,9 +125,8 @@ %D \macros %D {characters,Characters} %D -%D Converting large numbers is supported by the next two -%D macros. This time we just count on: $\cdots$~x, y, z, aa, -%D ab, ac~$\cdots$. +%D Converting large numbers is supported by the next two macros. This time we +%D just count on: $\cdots$~x, y, z, aa, ab, ac~$\cdots$. %D %D \showsetup{characters} %D \showsetup{Characters} @@ -163,20 +153,25 @@ \endgroup} \unexpanded\def\oldstyleromannumerals#1% will become obsolete - {\begingroup - \leftrulefalse - \rightrulefalse + {\dontleavehmode + \hbox\bgroup \ss\txx - \boxrulewidth.15ex - \ruledhbox spread .15em{\hss\uppercased{\romannumerals{#1}}\hss}% - \endgroup} + \setbox\scratchbox\hbox \s!spread .15\emwidth{\hss\uppercased{\romannumerals{#1}}\hss}% + \scratchwidth \wd\scratchbox + \scratchheight\ht\scratchbox + \scratchdimen .1\exheight + \vrule\s!width\scratchwidth\s!height\dimexpr\scratchheight+\scratchdimen\relax\s!depth-\dimexpr\scratchheight-+\scratchdimen\relax + \hskip-\scratchwidth + \vrule\s!width\scratchwidth\s!height\scratchdimen\s!depth\scratchdimen + \hskip-\scratchwidth + \box\scratchbox + \egroup} %D \macros %D {protectconversion} %D -%D The previous two commands are not robust enough to be -%D passed to \type{\write} en \type{\message}. That's why we -%D introduce: +%D The previous two commands are not robust enough to be passed to \type +%D {\write} en \type{\message}. That's why we introduce: \unexpanded\def\protectconversion {\let\doconvertcharacters\firstofoneargument} @@ -184,10 +179,9 @@ %D \macros %D {normaltime,normalyear,normalmonth,normalday} %D -%D The last part of this module is dedicated to converting -%D dates. Because we want to use as meaningful commands as -%D possible, and because \TEX\ already uses up some of those, -%D we save the original meanings. +%D The last part of this module is dedicated to converting dates. Because we +%D want to use as meaningful commands as possible, and because \TEX\ already +%D uses up some of those, we save the original meanings. \savenormalmeaning\time \savenormalmeaning\year @@ -197,10 +191,9 @@ %D \macros %D {month,MONTH} %D -%D Converting the month number into a month name is done -%D using a case statement, abstact values and the label -%D mechanism. This way users can easily redefine a label from -%D for instance german into austrian. +%D Converting the month number into a month name is done using a case statement, +%D abstact values and the label mechanism. This way users can easily redefine a +%D label from for instance german into austrian. %D %D \starttyping %D \setuplabeltext [de] [january=J\"anner] @@ -208,7 +201,7 @@ %D %D Anyhow, the conversion looks like: -\def\monthlong #1{\ctxcommand{month(#1)}} +\def\monthlong #1{\ctxcommand{monthname(#1)}} \def\monthshort#1{\ctxcommand{monthmnem(#1)}} \let\convertmonth\monthlong % for old times sake @@ -224,11 +217,9 @@ \def\MONTHLONG #1{\WORD{\monthlong {#1}}} \def\MONTHSHORT#1{\WORD{\monthshort{#1}}} -%D We never explicitly needed this, but Tobias Burnus pointed -%D out that it would be handy to convert to the day of the -%D week. In doing so, we have to calculate the total number of -%D days, taking leapyears into account. For those who are -%D curious: +%D We never explicitly needed this, but Tobias Burnus pointed out that it would be +%D handy to convert to the day of the week. In doing so, we have to calculate the +%D total number of days, taking leapyears into account. For those who are curious: %D %D \startitemize[packed] %D \item years that can be divided by 4 are leapyears @@ -239,8 +230,7 @@ %D \macros %D {weekday,WEEKDAY} %D -%D The first one is sort of redundant. It takes the day -%D number argument. +%D The first one is sort of redundant. It takes the day number argument. %D %D \showsetup{weekday} %D \showsetup{WEEKDAY} @@ -277,15 +267,15 @@ %D \getbuffer %D \stoplines %D -%D The macro \type {\getdayoftheweek} can be used to calculate -%D the number \type {\normalweekday}. +%D The macro \type {\getdayoftheweek} can be used to calculate the number +%D \type {\normalweekday}. %D \macros %D {doifleapyearelse, %D getdayspermonth} %D -%D Sometimes we need to know if we're dealing with a -%D leapyear, so here is a testmacro: +%D Sometimes we need to know if we're dealing with a leapyear, so here is a +%D testmacro: %D %D \starttyping %D \doifleapyearelse{year}{yes}{no} @@ -297,8 +287,7 @@ %D \getdayspermonth{year}{month} %D \stoptyping %D -%D The number of days is available in the macro \type -%D {\numberofdays}. +%D The number of days is available in the macro \type {\numberofdays}. \def\doifleapyearelse#1% {\ctxcommand{doifleapyearelse(\number#1)}} @@ -320,13 +309,11 @@ %D \macros %D {currentdate, rawdate, date} %D -%D We use these conversion macros in the date formatting -%D macro: +%D We use these conversion macros in the date formatting macro: %D %D \showsetup{currentdate} %D -%D This macro takes care of proper spacing and delivers for -%D instance: +%D This macro takes care of proper spacing and delivers for instance: %D %D \startbuffer %D \currentdate[weekday,day,month,year] % still dutch example @@ -351,8 +338,8 @@ %D %D or typeset: \getbuffer. %D -%D When no argument is passed, the current date is given as -%D specified per language (using \type{\installlanguage}). +%D When no argument is passed, the current date is given as specified per +%D language (using \type{\installlanguage}). %D %D \showsetup{currentdate} %D @@ -367,8 +354,8 @@ %D %D \typebuffer %D -%D The date is specified by one character keys. When no date -%D is given, we get the current date. +%D The date is specified by one character keys. When no date is given, we +%D get the current date. %D %D \startlines %D \getbuffer @@ -430,10 +417,13 @@ \def\syst_converters_date[#1][#2]% {\begingroup \iffirstargument - \getparameters[\??da][d=\normalday,m=\normalmonth,y=\normalyear,#1]% - \normalday \@@dad\relax - \normalmonth\@@dam\relax - \normalyear \@@day\relax + \letdummyparameter\c!d\normalday + \letdummyparameter\c!m\normalmonth + \letdummyparameter\c!y\normalyear + \getdummyparameters[#1]% + \normalday \directdummyparameter\c!d\relax + \normalmonth\directdummyparameter\c!m\relax + \normalyear \directdummyparameter\c!y\relax \fi \syst_converters_current_date[#2]% \endgroup} @@ -444,9 +434,8 @@ %D \macros %D {currenttime} %D -%D The currenttime is actually the jobtime. You can specify -%D a pattern similar to the previous date macro using the -%D keys \type {h}, \type {m} and a separator. +%D The currenttime is actually the jobtime. You can specify a pattern similar +%D to the previous date macro using the keys \type {h}, \type {m} and a separator. \unexpanded\def\calculatecurrenttime {\edef\currenthour {\ctxcommand{hour ()}}% @@ -462,7 +451,6 @@ \unexpanded\def\currenttime {\doifnextoptionalelse\syst_converters_current_time_yes\syst_converters_current_time_nop} - \unexpanded\def\syst_converters_current_time_yes[#1]% {\calculatecurrenttime \processallactionsinset[#1][h=>\currenthour,m=>\currentminute,\s!unknown=>\commalistelement]} @@ -471,16 +459,15 @@ {\normalexpanded{\syst_converters_current_time_yes[\currenttimespecification]}} -%D Because we're dealing with dates, we also introduce a few -%D day loops: +%D Because we're dealing with dates, we also introduce a few day loops: %D %D \starttyping %D \processmonth{year}{month}{command} %D \processyear{year}{command}{before}{after} %D \stoptyping %D -%D The counters \type {\normalyear}, \type {\normalmonth} and -%D \type{\normalday} can be used for for date manipulations. +%D The counters \type {\normalyear}, \type {\normalmonth} and \type {\normalday} +%D can be used for for date manipulations. \unexpanded\def\processmonth#1#2#3% year month command {\begingroup @@ -505,15 +492,13 @@ %D \macros %D {defineconversion, convertnumber} %D -%D Conversion involves the macros that we implemented earlier -%D in this module. +%D Conversion involves the macros that we implemented earlier in this module. %D %D \showsetup{defineconversion} %D \showsetup{convertnumber} %D -%D We can feed this command with conversion macros as well as -%D a set of conversion symbols. Both need a bit different -%D treatment. +%D We can feed this command with conversion macros as well as a set of conversion +%D symbols. Both need a bit different treatment. %D %D \starttyping %D \defineconversion [roman] [\romannumerals] @@ -549,9 +534,9 @@ \def\syst_converters_checked_conversion#1#2% {\ctxcommand{checkedconversion("#1",#2)}} -%D If a conversion is just a font switch then we need to make sure -%D that the number is indeed end up as number in the input, so we -%D need to handle the second argument. +%D If a conversion is just a font switch then we need to make sure that the +%D number is indeed ends up as number in the input, so we need to handle the +%D second argument. \def\convertnumber#1#2% expandable {\csname\??conversionarguments @@ -600,19 +585,20 @@ %D \macros %D {ordinaldaynumber, highordinalstr, ordinalstr} %D -%D Efficient general ordinal number converters are sometimes -%D difficult to implement. Fortunately dates never exceed the -%D number~31. +%D Efficient general ordinal number converters are sometimes difficult to +%D implement. Fortunately dates never exceed the number~31. \def\highordinalstr #1{\high{\notsmallcapped{#1}}} \def\ordinalstr #1{\notsmallcapped{#1}} \def\ordinaldaynumber #1{\ctxcommand{ordinal(#1,"\currentlanguage")}} -%D As longs as symbols are linked to levels or numbers, we can -%D also use the conversion mechanism, but in for instance the -%D itemization macros, we prefer symbols because they can more -%D easier be (partially) redefined. Symbols are implemented -%D in another module. +\def\verbosenumber #1{\ctxcommand{verbose(#1,"\currentlanguage")}} +\def\VerboseNumber #1{\Words{\ctxcommand{verbose(#1,"\currentlanguage")}}} + +%D As longs as symbols are linked to levels or numbers, we can also use the +%D conversion mechanism, but in for instance the itemization macros, we prefer +%D symbols because they can more easier be (partially) redefined. Symbols are +%D implemented in another module. \def\smallcappedromannumerals#1{\smallcapped{\romannumerals{#1}}} \def\smallcappedcharacters #1{\smallcapped{\characters {#1}}} @@ -641,6 +627,12 @@ \defineconversion [\v!Numbers] [\Numbers] \defineconversion [\v!mediaeval] [\mediaeval] +\defineconversion [\v!word] [\verbosenumber] +\defineconversion [\v!words] [\verbosenumber] + +\defineconversion [\v!Word] [\VerboseNumber] +\defineconversion [\v!Words] [\VerboseNumber] + \defineconversion [n] [\numbers] \defineconversion [N] [\Numbers] \defineconversion [m] [\mediaeval] |