summaryrefslogtreecommitdiff
path: root/tex/context
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-12-05 12:19:01 +0100
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-12-05 12:19:01 +0100
commit68136a0b476cd6d5bb8fb512b1dae4b1c697425b (patch)
treef1de9457d11c47dbc0d948d0332ce74375c72fb9 /tex/context
parenta87765fc8ba61e73b88a10cafdf5711ffeb84117 (diff)
downloadcyrillicnumbers-68136a0b476cd6d5bb8fb512b1dae4b1c697425b.tar.gz
titlo placement
Diffstat (limited to 'tex/context')
-rw-r--r--tex/context/third/cyrillicnumbers/cyrillicnumbers.lua57
-rw-r--r--tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv31
2 files changed, 43 insertions, 45 deletions
diff --git a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
index ab238ad..1c252ae 100644
--- a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
+++ b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua
@@ -76,31 +76,19 @@ local cyrillic_100k = utf8char(0x488) -- combining hundred thousands sign
local cyrillic_1m = utf8char(0x489) -- combining million sign
local cyrillic_titlo = utf8char(0x483) -- combining titlo
+cyrnum.last_synonyms = {
+ final = true,
+ last = true,
+ right = true,
+ rightmost = true,
+ ["false"] = true,
+}
---local concat_cyrillic_nums = function (chars, upper)
--- dbg(chars)
--- local nchars, result = tablemaxn(chars), ""
--- --if cyrnum.placetitlo and cyrnum.titlomode == "fm" then -- above central char
--- -- dbg("char cnt", nchars)
--- -- dbg("insert pos", mathceil(nchars/2))
--- -- tableinsert(chars, mathceil(nchars/2), cyrillic_titlo)
--- --end
--- for i=#chars, 1, -1 do
--- local this = chars[i]
--- if this then
--- if upper then this = utfupper(this) end
--- if i > 3 then
--- result = result .. cyrillic_1k .. this
--- else
--- result = result .. this
--- end
--- end
--- end
--- if cyrnum.placetitlo and cyrnum.titlomode == "fl" then -- take titlo from font, place it after / above last char
--- result = result .. cyrillic_titlo
--- end
--- return result
---end
+cyrnum.yes_synonyms = {
+ yes = true,
+ yeah = true,
+ ["true"] = true,
+}
local digits_only = function (list)
local result = { }
@@ -119,17 +107,24 @@ local start_titlo, stop_titlo = [[\cyrnumdrawtitlo{]], "}"
local titlofuncs = {
font = function (list)
- if cyrnum.titlolocation == "final" then
- list[#list+1] = cyrillic_titlo
- else -- “middle” or whatever
- local pos = mathceil(tablemaxn(list)/2)
- tableinsert(list, mathceil(tablemaxn(list)/2), cyrillic_titlo)
+ if cyrnum.titlolocation == "l" then
+ local result = lreverse(list)
+ result[#result+1] = cyrillic_titlo
+ return result
end
+ -- “middle” (“m”) or whatever
+ local pos = mathceil(tablemaxn(list)/2)
+ tableinsert(list, mathceil(tablemaxn(list)/2), cyrillic_titlo)
return lreverse(list)
end,
mp = function (list)
- local result = { start_titlo }
+ local result = { }
+ local titlospan = cyrnum.titlospan
+ local titlostart = titlospan and #list > titlospan and #list-titlospan or 1
for i=tablemaxn(list), 1, -1 do
+ if i == titlostart then
+ result[#result+1] = start_titlo
+ end
result[#result+1] = list[i]
end
result[#result+1] = stop_titlo
@@ -190,3 +185,5 @@ converters.Cyrillicnumerals = Tocyrillic
function commands.cyrillicnumerals (n) context(tocyrillic(n)) end
function commands.Cyrillicnumerals (n) context(Tocyrillic(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 8788c5e..79a47e6 100644
--- a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
+++ b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv
@@ -1,13 +1,13 @@
%D \module
-%D [ file=t-cyrillicnumbers,
-%D version=2011-11-29 09:58:48+0100,
-%D title=\CONTEXT\ User Module,
-%D subtitle=Cyrillic Number Module,
-%D author=Philipp Gesang,
-%D date=\currentdate,
-%D copyright=Philipp Gesang,
-%D license=2-clause BSD,
-%D email={gesang at stud dot uni-heidelberg dot de}]
+%D [ file=t-cyrillicnumbers,
+%D version=2011-11-29 09:58:48+0100,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Cyrillic Number Module,
+%D author=Philipp Gesang,
+%D date=\currentdate,
+%D copyright=Philipp Gesang,
+%D license=2-clause BSD,
+%D email={gesang at stud dot uni-heidelberg dot de}]
%D This module is licensed under the conditions of the BSD license with
%D two clauses. There is a copy in a file named "COPYING" in the
%D t-cyrillicnumbers source tree.
@@ -32,9 +32,9 @@
\startluacode
local tc = thirddata.cyrnum
tc.placetitlo = "\cyrnumparameter{titlo}"
- tc.titlospan = "\cyrnumparameter{titlospan}"
- tc.titlolocation = "\cyrnumparameter{titlolocation}"
- tc.drawdots = "\cyrnumparameter{dots}" == "yes"
+ tc.titlospan = tonumber("\cyrnumparameter{titlospan}") or false
+ tc.titlolocation = tc.last_synonyms["\cyrnumparameter{titlolocation}"] and "l" or "m"
+ tc.drawdots = tc. yes_synonyms["\cyrnumparameter{dots}"] or false
tc.dotsymbol = "\cyrnumparameter{dotsymbol}"
\stopluacode%
}
@@ -44,7 +44,7 @@
\setupcyrnum[
titlo=mp, % font|mp|no
titlospan=3, % n|all
- titlolocation=middle, % final|middle -- only effective if span ~= all
+ titlolocation=middle, % final|middle -- only effective if using the font’s titlo
dots=\v!yes, % yes|no
dotsymbol=·,
penwidth=3,
@@ -143,12 +143,12 @@
save penwidth ; penwidth = \cyrnumparameter{penwidth} ;
save High, Low ;
save Vfactor ; Vfactor = .20 ;
- save Hfactor ; Hfactor = .85 ;
+ save Hfactor ; Hfactor = .75 ;
titlo := ( 0.00, -0.8*Vfactor) {dir 90} .. {dir 90}
( 1.00, 1.2*Vfactor) ;
pickup pensquare yscaled penwidth xscaled 2 rotated 85 ;
draw titlo
- xysized (Hfactor*OverlayWidth-.5*penwidth,Vfactor*OverlayHeight)
+ xysized (Hfactor*OverlayWidth-penwidth,Vfactor*OverlayHeight)
shifted (.5*(OverlayWidth-Hfactor*OverlayWidth),OverlayHeight-Vfactor*OverlayHeight) ;
setbounds currentpicture to boundingbox OverlayBox ;
\stopuniqueMPgraphic
@@ -282,3 +282,4 @@
\unprotect \endinput
+% vi:ft=context:fo=co:ts=4:expandtab:sw=4