summaryrefslogtreecommitdiff
path: root/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/third/cyrillicnumbers/cyrillicnumbers.lua')
-rw-r--r--tex/context/third/cyrillicnumbers/cyrillicnumbers.lua50
1 files changed, 46 insertions, 4 deletions
diff --git a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
index 1c252ae..72ed5e4 100644
--- a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
+++ b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
@@ -37,6 +37,7 @@ local utfupper = unicode.utf8.upper
local cyrnum = {
placetitlo = "font",
+ prefer100k = false,
titlolocation = "final", -- above final digit
titlospan = 3, -- only with mp
drawdots = true,
@@ -90,12 +91,41 @@ cyrnum.yes_synonyms = {
["true"] = true,
}
+cyrnum.no_synonyms = {
+ no = true,
+ nope = true,
+ ["false"] = true,
+}
+
+local handle_plus1k = function (digit)
+ local before, after
+ if digit == 7 then
+ after = cyrillic_1m
+ elseif cyrnum.prefer100k and digit == 6 then
+ after = cyrillic_100k
+ elseif digit > 3 then -- insert thousand sign
+ before = cyrillic_1k
+ end
+ return before, after
+end
+
+-- digit list = {
+-- [1] = character to be printed
+-- [2] = real digit of character
+-- [3] = print this before character (e.g. thousand signs)
+-- [4] = print this after character (e.g. million signs)
+-- }
+
local digits_only = function (list)
local result = { }
for i=1, tablemaxn(list) do
local elm = list[i]
if type(elm) == "string" then
- result[#result+1] = elm
+ local before, after
+ if i > 3 then
+ before, after = handle_plus1k(i)
+ end
+ result[#result+1] = { elm, i, before, after } -- i contains the real digit
end
end
return result
@@ -120,12 +150,24 @@ local titlofuncs = {
mp = function (list)
local result = { }
local titlospan = cyrnum.titlospan
- local titlostart = titlospan and #list > titlospan and #list-titlospan or 1
+ local titlotype = cyrnum.titlotype
+ local titlostart = #list -- default to “all”
+ if titlotype == true then -- number
+ titlostart = (#list >= titlospan) and titlospan or #list
+ end
for i=tablemaxn(list), 1, -1 do
+ --local char, digit, before, after = list[i][1], list[i][2], list[i][
+ local char, digit, before, after = unpack(list[i])
if i == titlostart then
result[#result+1] = start_titlo
end
- result[#result+1] = list[i]
+ if before then
+ result[#result+1] = before
+ end
+ result[#result+1] = char
+ if after then
+ result[#result+1] = after
+ end
end
result[#result+1] = stop_titlo
return result
@@ -138,7 +180,7 @@ local concat_cyrillic_nums = function (list, upper)
local digits = digits_only(list) -- strip placeholders
local nlist, ndigits = tablemaxn(list), tablemaxn(digits)
dbg(list)
- dbg(digits)
+ --dbg(digits)
local titlo = titlofuncs[cyrnum.placetitlo]
if titlo then
result = tableconcat(titlo(digits))