summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/context/third/cyrillicnumbers/cyrillicnumbers.tex354
-rw-r--r--tex/context/third/cyrillicnumbers/cyrillicnumbers.lua51
-rw-r--r--tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv12
3 files changed, 361 insertions, 56 deletions
diff --git a/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex b/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex
index 7e56d9b..fcb2872 100644
--- a/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex
+++ b/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex
@@ -1,3 +1,5 @@
+\enablemode[print]
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Module loading %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -14,6 +16,18 @@
]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Colors %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\definecolor [primarycolor] [darkmagenta]
+\definecolor[secondarycolor] [magenta]
+
+\startmode[print]
+ \definecolor [primarycolor] [gray12]
+ \definecolor[secondarycolor] [gray22]
+\stopmode%%% print
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Letterspacing / emphases %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -28,7 +42,7 @@
\def\pompoustitle#1{%
\setuplocalinterlinespace[line=33pt]%
- \color[darkmagenta]{%
+ \color[primarycolor]{%
\tfd\bold\WORD\largecaps{#1}%
}%
}
@@ -44,7 +58,7 @@
\def\mediumtitle#1{%
\setuplocalinterlinespace[line=33pt]%
- \color[darkmagenta]{%
+ \color[primarycolor]{%
\tfa\sc\mediumcaps{#1}%
}%
}
@@ -71,15 +85,6 @@
]
\let\te\textemph
-\unexpanded\def\name#1{\smallcaps{\sc#1}}
-
-\defineletterspace [ugly]
-\setupletterspace [ugly] [
- factor=.4,
- spaceskip=1em,
- suppresskern=no,
-]
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Font Setups %
@@ -112,10 +117,9 @@
\usetypescriptfile [type-imp-computer-modern-unicode.mkiv]
\usetypescript [computer-modern-unicode]
-\def\russian#1{\begingroup\language[ru]\setupbodyfont[computer-modern-unicode]#1\endgroup}
-
+\def \russian#1{\begingroup\language[ru]\setupbodyfont[computer-modern-unicode]#1\endgroup}
\def\oldrussian#1{\begingroup\language[ru]\setupbodyfont[vintagecyrillic]#1\endgroup}
-\def\greek #1{\begingroup\language[agr]\setupbodyfont[computer-modern-unicode]#1\endgroup}
+\def \greek#1{\begingroup\language[agr]\setupbodyfont[computer-modern-unicode]#1\endgroup}
\usetypescript [modern]
\starttypescript [mymodern]
@@ -125,10 +129,6 @@
\usetypescript [mymodern]
\setupbodyfont [mymodern]
-% \setupbodyfont [modern]
-% \usetypescript [antykwa-poltawskiego]
-% \setupbodyfont [antykwa-poltawskiego,10pt]
-
\usetypescript [serif] [hz] [highquality]
\setupalign [hanging,hz]
@@ -138,7 +138,28 @@
\def\uprightslash{\bgroup\tf/\egroup}
\def\uprightomiss{\bgroup\tf[\dots]\egroup}
-% \setuptyping[style=\tfx\sans]
+%%% The Wiki is great. Long live the Gardener!
+\definetextbackground[verbatim] [
+ background=color,
+ backgroundcolor=gray92,
+ backgroundoffset=0cm,
+ frame=off,
+ location=paragraph,
+ offset=0.5cm,
+]
+
+\setuptyping[
+ after={\stoptextbackground\blank[line]},
+ before={\blank[line]\noindentation\starttextbackground[verbatim]},
+ bodyfont=9pt,
+ margin=1em,
+ % style=\tfx\sans,
+]
+
+%%% TODO: find out if this is documented already
+%%% http://archive.contextgarden.net/message/20060523.151528.b6da35e1.en.html
+%%% http://archive.contextgarden.net/message/20111221.083957.5c85d357.en.html
+\setconstant\kindofpagetextareas\plusone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Presenting the Interface %
@@ -154,8 +175,8 @@
\unexpanded\def\setupintfont {\rm\sc\Word}%
\unexpanded\def\setupvarfont {\rm\it}%
\unexpanded\def\setupoptfont {\rm\it}%
- \unexpanded\def\setupalwcolor {darkmagenta}%
- \unexpanded\def\setupoptcolor {darkmagenta}%
+ \unexpanded\def\setupalwcolor {primarycolor}%
+ \unexpanded\def\setupoptcolor {primarycolor}%
\defineframedtext [setuptext] [
frame=off,
background=color,
@@ -221,8 +242,8 @@
\setupinteraction[%
state=start,
- color=darkmagenta,
- contrastcolor=darkmagenta,
+ color=primarycolor,
+ contrastcolor=primarycolor,
%color=,
%contrastcolor=,
style=,
@@ -273,7 +294,6 @@
\definestructureconversionset[regularstructure] [numbers,cyrnumone,cyrnumtwo] [cyrnumone]
\definestructureconversionset[regularstructure] [numbers,cyrnumone,cyrnumtwo] [cyrnumone]
-% \definestructureconversionset[regularstructure] [numbers,romannumerals,romannumerals] [cyrnumone]
\setuphead [chapter] [
align=middle,
@@ -495,14 +515,36 @@
\setupindenting [yes,next,medium]
-\useURL [petr] [http://www.paratype.ru/e-zine/issue04/peter1/peter1a.htm] [] [\hyphenatedurl{http://www.paratype.ru/e-zine/issue04/peter1/peter1a.htm}]
-\useURL [reform1917] [http://ru.wikipedia.org/wiki/Реформа_русской_орфографии_1918_года] [] [\hyphenatedurl{http://ru.wikipedia.org/wiki/Реформа_русской_орфографии_1918_года}]
+% \sethyphenatedurlnormal{:=?&}
+\sethyphenatedurlbefore{?&abcdefghijklmnopqrstuvwxyz}
+% \sethyphenatedurlafter {:=}
+\startasciimode
+\useURL [petr] [http://www.paratype.ru/e-zine/issue04/peter1/peter1a.htm]
+ [] [\hyphenatedurl{http://www.paratype.ru/e-zine/issue04/peter1/peter1a.htm}]
+
+\useURL [reform1917] [http://ru.wikipedia.org/wiki/Реформа_русской_орфографии_1918_года]
+ [] [\hyphenatedurl{http://ru.wikipedia.org/wiki/Реформа_русской_орфографии_1918_года}]
+
+\useURL [wp_titlo] [http://commons.wikimedia.org/wiki/Category:Titlo?uselang=uk]
+ [] [\hyphenatedurl{http://commons.wikimedia.org/wiki/Category:Titlo?uselang=uk}]
+\useURL [rubl’] [http://ru.wikipedia.org/wiki/Рубль#.D0.92_.D0.98.D0.BC.D0.BF.D0.B5.D1.80.D0.B0.D1.82.D0.BE.D1.80.D1.81.D0.BA.D0.BE.D0.B9_.D0.A0.D0.BE.D1.81.D1.81.D0.B8.D0.B8]
+ [] [\hyphenatedurl{http://ru.wikipedia.org/wiki/Рубль#.D0.92_.D0.98.D0.BC.D0.BF.D0.B5.D1.80.D0.B0.D1.82.D0.BE.D1.80.D1.81.D0.BA.D0.BE.D0.B9_.D0.A0.D0.BE.D1.81.D1.81.D0.B8.D0.B8}]
\useURL [pttypescript] [http://archive.contextgarden.net/message/20110105.204326.d0228ca7.en.html]
-\useURL [phg-mail] [mailto:gesang@stud.uni-heidelberg.de] [] [\hyphenatedurl{gesang@stud.uni-heidelberg.de}]
+\useURL [phg-mail] [mailto:megas.kapaneus@gmail.com] [] [\hyphenatedurl{megas.kapaneus@gmail.com}]
\useURL [phg-bibu] [https://bitbucket.org/phg/] [] []
+\useURL [cmu-home] [http://cm-unicode.sourceforge.net/] [] [\hyphenatedurl{http://cm-unicode.sourceforge.net/}]
+\useURL [cmu-debian] [http://packages.debian.org/wheezy/fonts-cmu] [] [\hyphenatedurl{http://packages.debian.org/wheezy/fonts-cmu}]
+\useURL [cmu-arch] [http://aur.archlinux.org/packages.php?ID=44029] [] [\hyphenatedurl{http://aur.archlinux.org/packages.php?ID=44029}]
+\useURL [cmu-tl] [http://tug.org/svn/texlive/trunk/Master/texmf-dist/fonts/opentype/public/cm-unicode/]
+ [] [\hyphenatedurl{http://tug.org/svn/texlive/trunk/Master/texmf-dist/fonts/opentype/public/cm-unicode/}]
+\useURL [bukyvede] [http://kodeks.uni-bamberg.de/aksl/Schrift/BukyVede.htm]
+ [] [\hyphenatedurl{http://kodeks.uni-bamberg.de/aksl/Schrift/BukyVede.htm}]
+\useURL [romancyr] [http://kodeks.uni-bamberg.de/aksl/Schrift/RomanCyrillicStd.htm]
+ [] [\hyphenatedurl{http://kodeks.uni-bamberg.de/aksl/Schrift/RomanCyrillicStd.htm}]
+\stopasciimode
\pdfcompresslevel9
@@ -554,7 +596,7 @@
toffset=6pt,
]{%
\tfc%
- \dorecurse{9}{\normaltextcyrnum[titlo=mp,titlocolor=darkmagenta,titlomode=\recurselevel]{42}%
+ \dorecurse{9}{\normaltextcyrnum[titlo=mp,titlocolor=primarycolor,titlomode=\recurselevel]{42}%
\ifnum\recurselevel=9\else\hfill\fi}%
}%
}%
@@ -567,7 +609,7 @@
\dorecurse{6}{%
\recurselevel
\hfill
- \normaltextcyrnum[titlo=mp,titlomode=1,titlocolor=darkmagenta,titlospan=\recurselevel]{424242}%
+ \normaltextcyrnum[titlo=mp,titlomode=1,titlocolor=primarycolor,titlospan=\recurselevel]{424242}%
\ifnum\recurselevel<6\par\fi%
}
}%
@@ -577,7 +619,7 @@
\startbuffer[penwidthshowcase]%
\start\setuptolerance[horizontal,tolerant,stretch]%
% \placetable[left][penwidthdemo]{Comparison of different values for the parameter \type{penwidth}.}{%
-\placetable[bottom,left][penwidthdemo]{Comparison of different values for the parameter \type{penwidth}.}{%
+\placetable[middle][penwidthdemo]{Comparison of different values for the parameter \type{penwidth}.}{%
\starttabulate[|r|r|l|r|r|l|]%% tabulate sucks hard, just try to use it with a macro that contains a numberconversion and you’ll know why
\let\lp\letterpercent
\startluacode
@@ -593,6 +635,7 @@
\stopluacode
\stoptabulate%
}%
+\stop
\stopbuffer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -632,7 +675,7 @@
titlo=mp,
titlomode=\the\thistitlomode,
command=\showoldrussian,
- titlocolor=magenta,
+ titlocolor=secondarycolor,
]
\newdimen\skipincrement \skipincrement=0.047619047619048\hsize
\newdimen\showskip \showskip=\zeropoint
@@ -644,7 +687,7 @@
\dontleavehmode\hbox to\showskip{}%
\ifconditional\checker
\setfalse\checker
- \colored[darkmagenta]{\showcasecyrnum{\recurselevel}}%
+ \colored[primarycolor]{\showcasecyrnum{\recurselevel}}%
\else
\settrue\checker
\showcasecyrnum{\recurselevel}%
@@ -704,7 +747,8 @@ with the description on the module’s usage in the section on
\about[functionality].
\ctxluabuffer[showcase1]
-\indentation The Cyrillic system, like the alphabet
+\start\setuptolerance[horizontal,verytolerant]%% stupid float
+\indentation The Cyrillic numeral system, like the alphabet
it is based on, originated from the Greek numerals and thus
continues many features of the latter.\footnote{%
Thorough examinations of how Cyrillic numbers were used in
@@ -719,7 +763,10 @@ continues many features of the latter.\footnote{%
As with the Roman number system, there are no genuine glyphs
reserved for numerals, instead numbers are represented by strings
of letters from the ordinary alphabet, organized in a peculiar
-way.
+way; both systems also have the base (10) in common.
+However, unlike the Roman system Cyrillic numbers are
+\te{positional}, meaning that the numerical value of a digit
+depends on its location relative to the other digits.
The first nine digits, in ascending order, are:
\dorecurse{9}{\ifnum\recurselevel=9 and \fi%
“\normaltextcyrnum{\recurselevel}”%
@@ -747,7 +794,8 @@ For example, in the Cyrillic system the number 42 is written as
\normaltextcyrnum{42}; the lack of a distinct zero sign causes
402 to have \te{two} digits as well, but the character
representing the digit 4 gets chosen from the hundreds set:
-\normaltextcyrnum{402}.
+\normaltextcyrnum{402}.\par
+\stop
% above 10^3
The rules so far don’t allow for numbers above 999.
@@ -918,6 +966,14 @@ character above which it is placed.
Thus, multi-digit Cyrillic numbers (i.~e. essentially any number
with two or more non-zero digits) won’t be represented in an
optimal way: \normaltextcyrnum[titlo=font]{42}.
+There is a further option, \type{titlolocation}, which controls
+the placement of a font specific titlo.\marginhint{titlolocation}
+The three possible values specify a position
+{\italic first}: \normaltextcyrnum[titlo=font, titlolocation=first]{4242},
+{\italic middle}: \normaltextcyrnum[titlo=font,titlolocation=middle]{4242}, and
+{\italic final}: \normaltextcyrnum[titlo=font, titlolocation=final]{4242}.
+(For even character counts, the {\italic middle} argument will
+pick one place to the right of the exact middle.)
\getbuffer[titloshowcase]
\getbuffer[titlospanshowcase]\indentation An alternative to the
@@ -927,13 +983,18 @@ digits.
Not only does this titlo cover the entire numeral, it also comes
in a variety of drawing routines.
At the moment there are nine more or less different titlos you
-may choose from as demonstrated in \in{figure}[mptitlodemo].\marginhint{titlomode,titlospan}
+may choose from as demonstrated in \in{figure}[mptitlodemo].
These can be enabled on via the \type{titlomode} key.
+(Observant users will have recognized mode 8 as the old Rubl’
+sign:
+\normaltextcyrnum[titlo=mp,titlomode=8,penwidth=.21]{42}.\footnote{%
+ Cf. \from[rubl’].
+})
The range of digits to be covered by the titlo can be customized
by passing the parameter \type{titlospan} an integer.
The default value of 3 results in the titlo spanning at maximum the
least significant three digits, because these won’t be prefixed
-by a thousands sign.
+by a thousands sign.\marginhint{titlomode,titlospan}
If the user wants the numeral to be covered as a whole, E can
simply pass the value {\italic all}.
Beware that the dimensions of the titlo are proportional to the
@@ -949,31 +1010,152 @@ five digits plus two thousand signs of
When using the {\italic mp} titlo the color of this element can
be chosen separately by passing a valid color identifier to the
\type{titlocolor} key.\marginhint{titlocolor}
+The following example code demonstrates the colorization and
+drawing facilities.
+
+\starttyping
-\indentation The \METAPOST\ drawing options have separate keys.\marginhint{penwidth}
-Of these, \type{penwidth} rather obviously determines the width
-of the pen that is used when drawing a titlo.
-Finding the optimal width can involve a lot of testing;
-as a rule, the bigger the font, the wider the pen should be.
-See the table \about[penwidthdemo] for a demonstration of
+\usemodule [cyrillicnumbers]
+\setupbodyfont [computer-modern-unicode]
+\setupcyrnum [
+ titlo=mp,
+ titlocolor=blue,
+ titlospan=all,
+ titlomode=7,
+]
+
+\starttext
+\startlines
+\cyrnum {42}
+\cyrnum [titlocolor=red,titlomode=9] {141213}
+\cyrnum [titlocolor=green,titlomode=2] {271828}
+\cyrnum [titlocolor=cyan,titlomode=4] {314159}
+\stoplines
+\stoptext
+
+\stoptyping
+
+\indentation The \METAPOST\ option also comes with a key
+\marginhint{penwidth}, which rather obviously determines the
+width of the pen that is used when drawing a titlo.
+Finding the optimal width can involve a lot of testing on the
+user’s side; as a rule, the greater the font size, the wider the
+pen should be.
+Refer to \in{table}[penwidthdemo] for a demonstration of
different values for this parameter.
\getbuffer[penwidthshowcase]
-\stop
-
\stopsection
\startsection[title=Predefined Commands]
+Once the module is loaded, the commands \type{\cyrnum} and
+\type{\cyrnumdrawtitlo} will have been predefined.
+
\showsetup{cyrnum}
+
+\type{\cyrnum} is the default Cyrillic number macro which is
+fully functional, meaning that besides converting a nonnegative
+integer into a Cyrillic numeral, it takes a key-value set of
+options as an optional first argument.
+
+\starttyping
+\usemodule[cyrillicnumbers]
+\starttext
+
+\cyrnum{1}
+
+\cyrnum[titlo=mp,titlomode=4]{42}
+
+\cyrnum{15}
+
+\stoptext
+\stoptyping
+
+Any of the abovementioned settings can be specified in the first
+argument.
+As customary with \CONTEXT\ macros, these additional settings are
+local to one instance.
+Further calls to the macro won’t be affected, unless they are
+explicitly applied via \type{\setupcyrnum},
+
+The use of \te{titlos} is not restricted to indicating numerals.
+In addition it is often employed as a kind of emphasis in
+handwritten text where it is not easy to achieve visual
+distinction by font switching.
+Also, the titlo serves as a default marker for abbreviations as
+in \oldrussian{благодѣть} \rightarrow\space
+\oldrussian{\cyrnumdrawtitlo{блг}одѣть}.
+
\showsetup{cyrnumdrawtitlo}
-% \cyrnumdrawtitlo{foobar}
+This is where the macro \type{\cyrnumdrawtitlo} comes into play.
+For instance, designations of things considered “sacred” are
+highlighted by default in some texts.
+Because they appear very frequently, they were shortened as
+well, like \oldrussian{господь}
+\rightarrow\space\oldrussian{\cyrnumdrawtitlo{гь}}.\footnote{%
+ Examples taken from \from[wp_titlo].
+}
+
+\starttyping
+господь ->\cyrnumdrawtitlo{гь}
+
+благодѣть -> \cyrnumdrawtitlo{блг}одѣть
+\stoptyping
+
\stopsection
\startsection[title=Command Derivation]
+
+There is no need to reconfigure the \type{\cyrnum} macro whenever
+you intend to deviate from the presets.
+Instead, special purpose commands can be defined via
+\type{\definecyrnum}.
+
\showsetup{definecyrnum}
+All the options that can be passed to \type{\definecyrnum} are
+also valid for derived macros; they inherit the setups of
+the macros they are derived from.
+A full example to play with is given in below listing:
+
+\starttyping
+\usemodule[cyrillicnumbers]
+\setupbodyfont[computer-modern-unicode]
+
+\definecyrnum[mynumone][titlo=no,dots=no]
+
+\definecyrnum[mynumtwo][mynumone]
+\setupcyrnum [mynumtwo][titlo=mp,titlomode=2,titlocolor=red]
+
+\definecyrnum[mynumthree][mynumtwo]
+\setupcyrnum [mynumthree][titlomode=4,dots=yes]
+
+\starttext
+
+\mynumone{42}
+\mynumtwo{42}
+\mynumthree{42}
+
+\stoptext \endinput
+\stoptyping
+
+\start
+ \definecyrnum[mynumone][titlo=no,dots=no]
+
+ \definecyrnum[mynumtwo][mynumone]
+ \setupcyrnum [mynumtwo][titlo=mp,titlomode=2,titlocolor=red]
+
+ \definecyrnum[mynumthree][mynumtwo]
+ \setupcyrnum [mynumthree][titlomode=4,dots=yes]
+
+ \noindentation Which results in:
+ \mynumone{42}
+ \mynumtwo{42}
+ \mynumthree{42}.
+\stop
+
\stopsection
\stopchapter
@@ -983,12 +1165,88 @@ different values for this parameter.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\startsection[title=Counters]
-\stopsection
+The macros created by \type{\definecyrnum} are generic conversion
+commands.
+As such, they can be hooked into any functionality that outputs
+integers of some sort: document structure elements, page numbers
+{\italic\letterampersand}c.
+In order to have \CONTEXT\ recognize your personal Cyrillic
+number macro as a converter you need the macro
+\type{\defineconversion}.
+
+\starttyping
+\usemodule [cyrillicnumbers]
+\setupbodyfont [computer-modern-unicode]
+
+%%% 1. Define a number converter.
+\definecyrnum [neatsections] [
+ dots=yes,
+ titlo=mp,
+ titlomode=7,
+]
+
+%%% 2. Register the converter.
+\defineconversion [my_section_conversion] [\neatsections]
+
+%%% 3. Insert it into a structure set.
+\definestructureconversionset [my_section_set]
+ [numbers,my_section_conversion] [my_section_conversion]
+
+%%% 4. Use the set in your chapter command.
+\definehead [mychapter] [chapter]
+\setuphead [mychapter] [
+ sectionconversionset=my_section_set,
+ page=no,
+]
+
+\starttext
+
+\dorecurse{10}{%
+ \startmychapter[title=foo]
+ \input knuth
+ \stopmychapter
+}
+
+\stoptext \endinput
+\stoptyping
-\startsection[title=The Titlo]
\stopsection
+% \startsection[title=The Titlo]
+% \stopsection
+
\startsection[title=Font Issues]
+
+Although not the entire Cyrillic alphabet is needed to represent
+the numerals, they involve certain characters which are uncommon
+in contemporary languages.
+Therefore they are usually omitted in Cyrillic fonts, which leads
+to the problem of finding an adequate font.
+A matching superset of Knuth’s typeface is {\italic Computer Modern
+Unicode} which is part of \TEX Live and packaged for many
+distributions.\footnote{%
+ Home: \from[cmu-home];
+ \TEX Live: \from[cmu-tl];
+ Arch: \from[cmu-arch];
+ Debian: \from[cmu-debian].
+}
+CMU is SIL-OpenFont licensed; it has been used in some of the
+above examples.
+
+There are alternatives offering glyph shapes that resemble the
+hand written script of Old Slavonic codices.
+One of them is the beautiful {\italic BukyVede} which has been
+used as the main Cyrillic font throughout the text.
+It was created by the Codex project of the Bamberg
+University\footnote{%
+ Home: \from[bukyvede].
+}
+but unfortunately the licensing terms are imprecise (non-free).
+Its authors offer another font matching the popular Times
+typeface under a yet more restrictive license.\footnote{%
+ Home: \from[romancyr].
+}
+
\stopsection
\stopchapter
diff --git a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
index cec98c7..2041ead 100644
--- a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
+++ b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
@@ -32,15 +32,16 @@ http://ru.wikipedia.org/wiki/Кириллическая_система_счис
</typing>
--ldx]]--
-local iowrite = io.write
-local mathceil = math.ceil
-local mathfloor = math.floor
-local tableconcat = table.concat
+local iowrite = io.write
+local mathceil = math.ceil
+local mathfloor = math.floor
+local stringformat = string.format
+local tableconcat = table.concat
--local tablemaxn = table.maxn
-local tableinsert = table.insert
-local utf8char = unicode.utf8.char
-local utf8len = unicode.utf8.len
-local utfupper = unicode.utf8.upper
+local tableinsert = table.insert
+local utf8char = unicode.utf8.char
+local utf8len = unicode.utf8.len
+local utfupper = unicode.utf8.upper
local cyrnum = {
placetitlo = "font",
@@ -286,4 +287,38 @@ converters.Cyrillicnumerals = Tocyrillic
function commands.cyrillicnumerals (n) context(tocyrillic(n)) end
function commands.Cyrillicnumerals (n) context(Tocyrillic(n)) end
+--- Fun ---------------------------------------------------------
+
+local f_peano = [[suc(%s)]]
+local do_topeano = function (n)
+ n = tonumber(n) or 0
+ if n == 0 then return "0" end
+ local result = stringformat(f_peano, 0)
+ if n == 1 then return result end
+ for i=2, n do
+ result = stringformat(f_peano, result)
+ end
+ return result
+end
+
+local s_churchp = [[λf.λx.\;]]
+local s_church0 = [[x]]
+local s_church1 = [[f\,x]]
+local f_church = [[f(%s)]]
+local do_tochurch = function (n)
+ if n == 0 then return s_churchp .. s_church0
+ elseif n == 1 then return s_churchp .. s_church1 end
+ local result = stringformat(f_church, s_church1)
+ for i=2, n do
+ result = stringformat(f_church, result)
+ end
+ return s_churchp .. result
+end
+
+converters.topeano = do_topeano
+converters.tochurch = do_tochurch
+
+commands.peanonumerals = function (n) context(do_topeano(n)) end
+commands.churchnumerals = function (n) context.mathematics(do_tochurch(n)) end
+
-- vim:ft=lua:ts=2:sw=2:expandtab:fo=croql
diff --git a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
index e087a43..291f562 100644
--- a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
+++ b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
@@ -454,6 +454,18 @@
\defineconversion[cyr] [\cyrillicnumerals]
\defineconversion[Cyr] [\Cyrillicnumerals]
+% \unprotect \endinput
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Fun %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\peano#1{\ctxcommand{peanonumerals(\number#1)}}
+\defineconversion[peano][\peano]
+
+\def\church#1{\ctxcommand{churchnumerals(\number#1)}}
+\defineconversion[church][\church]
+
\unprotect \endinput
% vi:ft=context:fo=co:ts=2:expandtab:sw=2