summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/util-dim.lua
diff options
context:
space:
mode:
authorMojca Miklavec <mojca.miklavec@gmail.com>2014-05-05 20:29:55 +0000
committerMojca Miklavec <mojca.miklavec@gmail.com>2014-05-05 20:29:55 +0000
commitba9a57343987f1c2c72396e7c38f1fa30352c24c (patch)
tree66a8b12cdf67427ce96770fd0e9e581759aade1c /Master/texmf-dist/tex/context/base/util-dim.lua
parent15242121b8ddf7d4a041fb3998d295dd8232e1eb (diff)
ConTeXt 2014.04.28 23:24
git-svn-id: svn://tug.org/texlive/trunk@33856 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/util-dim.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/util-dim.lua32
1 files changed, 17 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/context/base/util-dim.lua b/Master/texmf-dist/tex/context/base/util-dim.lua
index 47b2706b736..69061495f94 100644
--- a/Master/texmf-dist/tex/context/base/util-dim.lua
+++ b/Master/texmf-dist/tex/context/base/util-dim.lua
@@ -22,6 +22,8 @@ local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
local formatters = string.formatters
+local texget = tex and tex.get or function() return 65536*10*100 end
+
--this might become another namespace
number = number or { }
@@ -137,7 +139,7 @@ capture takes place.</p>
--ldx]]--
local amount = (S("+-")^0 * R("09")^0 * P(".")^0 * R("09")^0) + Cc("0")
-local unit = R("az")^1
+local unit = R("az")^1 + P("%")
local dimenpair = amount/tonumber * (unit^1/dimenfactors + Cc(1)) -- tonumber is new
@@ -376,10 +378,10 @@ function dimen(a)
a = k
else
local value, unit = lpegmatch(dimenpair,a)
- if type(unit) == "function" then
- k = value/unit()
+ if value and unit then
+ k = value/unit -- to be considered: round
else
- k = value/unit
+ k = 0
end
known[a] = k
a = k
@@ -412,16 +414,16 @@ function string.todimen(str) -- maybe use tex.sp when available
end
end
---~ local known = { }
-
---~ function string.todimen(str) -- maybe use tex.sp
---~ local k = known[str]
---~ if not k then
---~ k = tex.sp(str)
---~ known[str] = k
---~ end
---~ return k
---~ end
+-- local known = { }
+--
+-- function string.todimen(str) -- maybe use tex.sp
+-- local k = known[str]
+-- if not k then
+-- k = tex.sp(str)
+-- known[str] = k
+-- end
+-- return k
+-- end
stringtodimen = string.todimen -- local variable defined earlier
@@ -439,7 +441,7 @@ probably use a hash instead of a one-element table.</p>
--ldx]]--
function number.percent(n,d) -- will be cleaned up once luatex 0.30 is out
- d = d or tex.hsize
+ d = d or texget("hsize")
if type(d) == "string" then
d = stringtodimen(d)
end