summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-11-01 16:20:13 +0200
committerMarius <mariausol@gmail.com>2013-11-01 16:20:13 +0200
commit7d896afa09526aee508c4484f1bf61f7139c752b (patch)
tree10ffaf0ccdfbd6e0c178cd3d3dd8aadb0f201dd5 /tex
parent1d04224cdd84e606f0c70a47d10acc231f271b9f (diff)
downloadcontext-7d896afa09526aee508c4484f1bf61f7139c752b.tar.gz
beta 2013.11.01 15:02
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4109 -> 4107 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/m-graph.mkiv45
-rw-r--r--tex/context/base/meta-tex.lua113
-rw-r--r--tex/context/base/meta-tex.mkiv4
-rw-r--r--tex/context/base/mult-fun.lua2
-rw-r--r--tex/context/base/mult-mps.lua2
-rw-r--r--tex/context/base/status-files.pdfbin24550 -> 24535 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin224966 -> 225201 bytes
-rw-r--r--tex/context/base/util-str.lua45
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua42
12 files changed, 212 insertions, 45 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index a75ebe429..a421678d7 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.11.01 12:20}
+\newcontextversion{2013.11.01 15:02}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 7eb11112d..7d6ad88e5 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 7dc482a97..e40bdb0ab 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -25,7 +25,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.11.01 12:20}
+\edef\contextversion{2013.11.01 15:02}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv
index 978b20eeb..64cf46157 100644
--- a/tex/context/base/m-graph.mkiv
+++ b/tex/context/base/m-graph.mkiv
@@ -35,20 +35,37 @@
\starttext
\startMPpage[instance=graph]
- label(format("@g","1e-8"), (0, 0)) ;
- label(format("@g","1e+8"), (2cm, 0)) ;
- label(format("@g","1e-10"), (0, -0.5cm)) ;
- label(format("@g","1e+10"), (2cm,-0.5cm)) ;
- label(format("@g","1e-12"), (0, -1.0cm)) ;
- label(format("@g","1e+12"), (2cm,-1.0cm)) ;
- label(format("@g","1e-0"), (0, -1.5cm)) ;
- label(format("@g","1e+0"), (2cm,-1.5cm)) ;
- label(format("@g","1"), (0, -2.0cm)) ;
- label(format("@g","1"), (2cm,-2.0cm)) ;
- label(format("@g","1e-102"),(0, -2.5cm)) ;
- label(format("@g","1e+102"),(2cm,-2.5cm)) ;
- label(format("@f,@f",(1.23,4.56)),(0cm,-3.0cm)) ;
- label(format("@i,@f",(1.23,4.56)),(0cm,-3.5cm)) ;
+ label.rt(format("@g","1e-8"), (0, 0)) ;
+ label.rt(format("@g","1e+8"), (2cm, 0)) ;
+ label.rt(format("@g","1e-10"), (0, -0.5cm)) ;
+ label.rt(format("@g","1e+10"), (2cm,-0.5cm)) ;
+ label.rt(format("@g","1e-12"), (0, -1.0cm)) ;
+ label.rt(format("@g","1e+12"), (2cm,-1.0cm)) ;
+ label.rt(format("@g","1e-0"), (0, -1.5cm)) ;
+ label.rt(format("@g","1e+0"), (2cm,-1.5cm)) ;
+ label.rt(format("@g","1"), (0, -2.0cm)) ;
+ label.rt(format("@g","1"), (2cm,-2.0cm)) ;
+ label.rt(format("@g","1e-102"),(0, -2.5cm)) ;
+ label.rt(format("@g","1e+102"),(2cm,-2.5cm)) ;
+ currentpicture := currentpicture shifted (-4cm,0) ;
+ %
+ label.rt(format("@j","1e-8"), (0, 0)) ;
+ label.rt(format("@j","1e+8"), (2cm, 0)) ;
+ label.rt(format("@j","1e-10"), (0, -0.5cm)) ;
+ label.rt(format("@j","1e+10"), (2cm,-0.5cm)) ;
+ label.rt(format("@j","1e-12"), (0, -1.0cm)) ;
+ label.rt(format("@j","1e+12"), (2cm,-1.0cm)) ;
+ label.rt(format("@j","1e-0"), (0, -1.5cm)) ;
+ label.rt(format("@j","1e+0"), (2cm,-1.5cm)) ;
+ label.rt(format("@j","1"), (0, -2.0cm)) ;
+ label.rt(format("@j","1"), (2cm,-2.0cm)) ;
+ label.rt(format("@j","1e-102"),(0, -2.5cm)) ;
+ label.rt(format("@j","1e+102"),(2cm,-2.5cm)) ;
+ label.rt(formatted("(@f,@f)",(1.23,4.56)),(0cm,-3.0cm)) ;
+ label.rt(formatted("(@i,@i)",(1.23,4.56)),(0cm,-3.5cm)) ;
+ label.rt(formatted("(@g,@g)",(1.23,4.56)),(0cm,-4.0cm)) ;
+ label.rt(formatted("(@e,@e)",(1.23,4.56)),(0cm,-4.5cm)) ;
+ label.rt(formatted("(@j,@j)",(1.23,4.56)),(0cm,-5.0cm)) ;
\stopMPpage
\stoptext
diff --git a/tex/context/base/meta-tex.lua b/tex/context/base/meta-tex.lua
index 94815495d..e1398e7ed 100644
--- a/tex/context/base/meta-tex.lua
+++ b/tex/context/base/meta-tex.lua
@@ -7,8 +7,10 @@ if not modules then modules = { } end modules ['meta-tex'] = {
}
local format, gsub, find, match = string.format, string.gsub, string.find, string.match
+local formatters = string.formatters
+local P, S, R, C, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cs, lpeg.match
-local P, C, Cs, lpegmatch = lpeg.P, lpeg.C, lpeg.Cs, lpeg.match
+metapost = metapost or { }
-- local left = P("[")
-- local right = P("]")
@@ -70,31 +72,96 @@ local simplify = true
-- todo: proper lpeg
-local function strip(n,e)
- -- get rid of e(0)
- -- get rid of e(+*)
- e = gsub(e,"^+","")
- -- remove leading zeros
- e = gsub(e,"^([+-]*)0+(%d)","%1%2")
- if not simplify then
- -- take it as it is
- elseif n == "1" then
- return format("\\mathematics{10^{%s}}",e)
- end
- return format("\\mathematics{%s\\times10^{%s}}",n,e)
+-- local function strip(n,e)
+-- -- get rid of e(0)
+-- -- get rid of e(+*)
+-- e = gsub(e,"^+","")
+-- -- remove leading zeros
+-- e = gsub(e,"^([+-]*)0+(%d)","%1%2")
+-- if not simplify then
+-- -- take it as it is
+-- elseif n == "1" then
+-- return format("\\mathematics{10^{%s}}",e)
+-- end
+-- return format("\\mathematics{%s\\times10^{%s}}",n,e)
+-- end
+--
+-- function metapost.format_n(fmt,...)
+-- fmt = gsub(fmt,"@","%%")
+-- if find(fmt,"%%") then
+-- str = format(fmt,...)
+-- else -- yes or no
+-- str = format("%"..fmt,...)
+-- end
+-- str = gsub(str,"([%-%+]-[%.%d]+)e([%-%+]-[%.%d]+)",strip)
+-- context(str)
+-- end
+--
+-- function metapost.format_v(fmt,str)
+-- metapost.format_n(fmt,metapost.untagvariable(str,false))
+-- end
+
+-- -- --
+
+local number = C((S("+-")^0 * R("09","..")^1))
+local enumber = number * S("eE") * number
+
+local cleaner = Cs((P("@@")/"@" + P("@")/"%%" + P(1))^0)
+
+function format_n(fmt,...)
+ return
end
-function metapost.format_n(fmt,...)
- fmt = gsub(fmt,"@","%%")
- if find(fmt,"%%") then
- str = format(fmt,...)
- else -- yes or no
- str = format("%"..fmt,...)
+context = context or { exponent = function(...) print(...) end }
+
+function metapost.format_string(fmt,...)
+ context(lpegmatch(cleaner,fmt),...)
+end
+
+function metapost.format_number(fmt,num)
+ local number = tonumber(num)
+ if number then
+ local base, exponent = lpegmatch(enumber,formatters[lpegmatch(cleaner,fmt)](number))
+ if base and exponent then
+ context.MPexponent(base,exponent)
+ else
+ context(number)
+ end
+ else
+ context(tostring(num))
end
- str = gsub(str,"([%-%+]-[%.%d]+)e([%-%+]-[%.%d]+)",strip)
- context(str)
end
-function metapost.format_v(fmt,str)
- metapost.format_n(fmt,metapost.untagvariable(str,false))
+function metapost.svformat(fmt,str)
+ metapost.format_string(fmt,metapost.untagvariable(str,false))
+end
+
+function metapost.nvformat(fmt,str)
+ metapost.format_number(fmt,metapost.untagvariable(str,false))
end
+
+-- local function test(fmt,n)
+-- logs.report("mp format test","fmt: %s, n: %s, result: %s, \\exponent{%s}{%s}",fmt,n,
+-- formatters[lpegmatch(cleaner,fmt)](n),
+-- lpegmatch(enumber,formatters[lpegmatch(cleaner,fmt)](n))
+-- )
+-- end
+--
+-- test("@j","1e-8")
+-- test("@j",1e-8)
+-- test("@j","1e+8")
+-- test("@j","1e-10")
+-- test("@j",1e-10)
+-- test("@j","1e+10")
+-- test("@j","1e-12")
+-- test("@j","1e+12")
+-- test("@j","1e-0")
+-- test("@j","1e+0")
+-- test("@j","1")
+-- test("@j test","1")
+-- test("@j","-1")
+-- test("@j","1e-102")
+-- test("@1.4j","1e+102")
+-- test("@j","1.2e+102")
+-- test("@j","1.23e+102")
+-- test("@j","1.234e+102")
diff --git a/tex/context/base/meta-tex.mkiv b/tex/context/base/meta-tex.mkiv
index 9392e3fc9..deac883c8 100644
--- a/tex/context/base/meta-tex.mkiv
+++ b/tex/context/base/meta-tex.mkiv
@@ -138,6 +138,8 @@
%
% {\showstruts\useMPgraphic{testgraphic}}
-\unexpanded\def\MPgraphformat#1#2{\ctxlua{metapost.format_v("#1","#2")}}
+\unexpanded\def\MPexponent #1#2{\mathematics{#1\times10^{#2}}}
+\unexpanded\def\MPformatted #1#2{\ctxlua{metapost.svformat("#1","#2")}}
+\unexpanded\def\MPgraphformat#1#2{\ctxlua{metapost.nvformat("#1","#2")}}
\protect \endinput
diff --git a/tex/context/base/mult-fun.lua b/tex/context/base/mult-fun.lua
index 3167fe7bf..fea1b0cc0 100644
--- a/tex/context/base/mult-fun.lua
+++ b/tex/context/base/mult-fun.lua
@@ -100,6 +100,6 @@ return {
--
"decorated", "redecorated", "undecorated",
--
- "passvariable", "tostring"
+ "passvariable", "tostring", "format", "formatted",
},
}
diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua
index 5a320487a..d50beb640 100644
--- a/tex/context/base/mult-mps.lua
+++ b/tex/context/base/mult-mps.lua
@@ -58,6 +58,8 @@ return {
-- "colorpart",
"stroked", "filled", "textual", "clipped", "bounded", "pathpart",
"expandafter",
+ "minute", "hour", "outputformat", "outputtemplate", "filenametemplate", "fontmapfile", "fontmapline",
+ "fontpart", "fontsize", "glyph", "restoreclipcolor", "troffmode",
},
commands = {
"beginfig", "endfig",
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 05cfa59c1..db17dcbd9 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 09d41b7da..46c3ef27e 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/util-str.lua b/tex/context/base/util-str.lua
index 295fc0044..09fa26f94 100644
--- a/tex/context/base/util-str.lua
+++ b/tex/context/base/util-str.lua
@@ -264,6 +264,33 @@ function number.signed(i)
end
end
+local zero = P("0")^1 / ""
+local plus = P("+") / ""
+local minus = P("-")
+local separator = S(".")
+local digit = R("09")
+local trailing = zero^1 * #S("eE")
+local exponent = (S("eE") * (plus + Cs((minus * zero^0 * P(-1))/"") + minus) * zero^0 * (P(-1) * Cc("0") + P(1)^1))
+local pattern_a = Cs(minus^0 * digit^1 * (separator/"" * trailing + separator * (trailing + digit)^0) * exponent)
+local pattern_b = Cs((exponent + P(1))^0)
+
+function number.sparseexponent(f,n)
+ if not n then
+ n = f
+ f = "%e"
+ end
+ local tn = type(n)
+ if tn == "string" then -- cast to number
+ local m = tonumber(n)
+ if m then
+ return lpegmatch((f == "%e" or f == "%E") and pattern_a or pattern_b,format(f,m))
+ end
+ elseif tn == "number" then
+ return lpegmatch((f == "%e" or f == "%E") and pattern_a or pattern_b,format(f,n))
+ end
+ return tostring(n)
+end
+
local preamble = [[
local type = type
local tostring = tostring
@@ -282,6 +309,7 @@ local autosingle = string.autosingle
local autodouble = string.autodouble
local sequenced = table.sequenced
local formattednumber = number.formatted
+local sparseexponent = number.sparseexponent
]]
local template = [[
@@ -376,6 +404,16 @@ local format_E = function(f)
return format("format('%%%sE',a%s)",f,n)
end
+local format_j = function(f)
+ n = n + 1
+ return format("sparseexponent('%%%se',a%s)",f,n)
+end
+
+local format_J = function(f)
+ n = n + 1
+ return format("sparseexponent('%%%sE',a%s)",f,n)
+end
+
local format_x = function(f)
n = n + 1
return format("format('%%%sx',a%s)",f,n)
@@ -602,6 +640,8 @@ local format_extension = function(extensions,f,name)
end
end
+-- aA b cC d eE f gG hH iI jJ lL mM N o p qQ r sS tT uU wW xX
+
local builder = Cs { "start",
start = (
(
@@ -625,11 +665,11 @@ local builder = Cs { "start",
+ V("t") + V("T")
+ V("l") + V("L")
+ V("I")
- + V("h") -- new
+ V("w") -- new
+ V("W") -- new
+ V("a") -- new
+ V("A") -- new
+ + V("j") + V("J") -- stripped e E
+ V("m") + V("M") -- new
--
+ V("*") -- ignores probably messed up %
@@ -674,6 +714,9 @@ local builder = Cs { "start",
["w"] = (prefix_any * P("w")) / format_w, -- %w => n spaces (optional prefix is added)
["W"] = (prefix_any * P("W")) / format_W, -- %W => mandate prefix, no specifier
--
+ ["j"] = (prefix_any * P("j")) / format_j, -- %j => %e (float) stripped exponent (irrational)
+ ["J"] = (prefix_any * P("J")) / format_J, -- %J => %E (float) stripped exponent (irrational)
+ --
["m"] = (prefix_tab * P("m")) / format_m, -- %m => xxx.xxx.xxx,xx (optional prefix instead of .)
["M"] = (prefix_tab * P("M")) / format_M, -- %M => xxx,xxx,xxx.xx (optional prefix instead of ,)
--
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 41ed20fdc..03b817496 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 11/01/13 12:20:30
+-- merge date : 11/01/13 15:02:08
do -- begin closure to overcome local limits and interference
@@ -2613,6 +2613,31 @@ function number.signed(i)
return "-",-i
end
end
+local zero=P("0")^1/""
+local plus=P("+")/""
+local minus=P("-")
+local separator=S(".")
+local digit=R("09")
+local trailing=zero^1*#S("eE")
+local exponent=(S("eE")*(plus+Cs((minus*zero^0*P(-1))/"")+minus)*zero^0*(P(-1)*Cc("0")+P(1)^1))
+local pattern_a=Cs(minus^0*digit^1*(separator/""*trailing+separator*(trailing+digit)^0)*exponent)
+local pattern_b=Cs((exponent+P(1))^0)
+function number.sparseexponent(f,n)
+ if not n then
+ n=f
+ f="%e"
+ end
+ local tn=type(n)
+ if tn=="string" then
+ local m=tonumber(n)
+ if m then
+ return lpegmatch((f=="%e" or f=="%E") and pattern_a or pattern_b,format(f,m))
+ end
+ elseif tn=="number" then
+ return lpegmatch((f=="%e" or f=="%E") and pattern_a or pattern_b,format(f,n))
+ end
+ return tostring(n)
+end
local preamble=[[
local type = type
local tostring = tostring
@@ -2631,6 +2656,7 @@ local autosingle = string.autosingle
local autodouble = string.autodouble
local sequenced = table.sequenced
local formattednumber = number.formatted
+local sparseexponent = number.sparseexponent
]]
local template=[[
%s
@@ -2703,6 +2729,14 @@ local format_E=function(f)
n=n+1
return format("format('%%%sE',a%s)",f,n)
end
+local format_j=function(f)
+ n=n+1
+ return format("sparseexponent('%%%se',a%s)",f,n)
+end
+local format_J=function(f)
+ n=n+1
+ return format("sparseexponent('%%%sE',a%s)",f,n)
+end
local format_x=function(f)
n=n+1
return format("format('%%%sx',a%s)",f,n)
@@ -2893,11 +2927,11 @@ local builder=Cs { "start",
+V("c")+V("C")+V("S")
+V("Q")
+V("N")
-+V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("b")+V("t")+V("T")+V("l")+V("L")+V("I")+V("h")
-+V("w")
++V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("b")+V("t")+V("T")+V("l")+V("L")+V("I")+V("w")
+V("W")
+V("a")
+V("A")
++V("j")+V("J")
+V("m")+V("M")
+V("*")
)+V("*")
@@ -2934,6 +2968,8 @@ local builder=Cs { "start",
["I"]=(prefix_any*P("I"))/format_I,
["w"]=(prefix_any*P("w"))/format_w,
["W"]=(prefix_any*P("W"))/format_W,
+ ["j"]=(prefix_any*P("j"))/format_j,
+ ["J"]=(prefix_any*P("J"))/format_J,
["m"]=(prefix_tab*P("m"))/format_m,
["M"]=(prefix_tab*P("M"))/format_M,
["a"]=(prefix_any*P("a"))/format_a,