summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2014-02-14 18:20:22 +0200
committerMarius <mariausol@gmail.com>2014-02-14 18:20:22 +0200
commit088de88944c1f2254250bb448c7371a87ff7ee39 (patch)
treee6fda41d633606d832db5bacfef2d9bd05e6c881 /tex
parent43b2c43c53673bbaebc0cec57d32c4609c026cd9 (diff)
downloadcontext-088de88944c1f2254250bb448c7371a87ff7ee39.tar.gz
beta 2014.02.14 17:07
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4092 -> 4096 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/l-lua.lua4
-rw-r--r--tex/context/base/lpdf-mis.lua74
-rw-r--r--tex/context/base/math-ini.lua10
-rw-r--r--tex/context/base/mult-def.mkiv1
-rw-r--r--tex/context/base/status-files.pdfbin24794 -> 24795 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin226990 -> 226993 bytes
-rw-r--r--tex/context/base/strc-pag.lua12
-rw-r--r--tex/context/base/strc-pag.mkiv5
-rw-r--r--tex/context/base/util-str.lua170
-rw-r--r--tex/context/base/util-tab.lua3
-rw-r--r--tex/context/base/x-mathml.lua3
-rw-r--r--tex/context/base/x-mathml.mkiv4
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua127
16 files changed, 278 insertions, 139 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 6058b3e1b..733afc6d0 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{2014.02.13 11:27}
+\newcontextversion{2014.02.14 17:07}
%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 cdb6bdceb..275625528 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 c5708f2dd..8c67fbd50 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -28,7 +28,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2014.02.13 11:27}
+\edef\contextversion{2014.02.14 17:07}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/l-lua.lua b/tex/context/base/l-lua.lua
index 233e1aa0f..4a96b0b1d 100644
--- a/tex/context/base/l-lua.lua
+++ b/tex/context/base/l-lua.lua
@@ -151,4 +151,6 @@ end
-- nice for non ascii scripts (this might move):
-lua.mask = load([[τεχ = 1]]) and "utf" or "ascii"
+if lua then
+ lua.mask = load([[τεχ = 1]]) and "utf" or "ascii"
+end
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index 174d17427..43f6cb7e1 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -43,6 +43,7 @@ local pdfflushobject = lpdf.flushobject
local pdfflushstreamobject = lpdf.flushstreamobject
local variables = interfaces.variables
+local v_stop = variables.stop
local positive = register(pdfliteral("/GSpositive gs"))
local negative = register(pdfliteral("/GSnegative gs"))
@@ -337,31 +338,82 @@ local map = {
characters = "a",
}
+-- local function featurecreep()
+-- local pages, lastconversion, list = structures.pages.tobesaved, nil, pdfarray()
+-- local getstructureset = structures.sets.get
+-- for i=1,#pages do
+-- local p = pages[i]
+-- if not p then
+-- return -- fatal error
+-- else
+-- local numberdata = p.numberdata
+-- if numberdata then
+-- local conversionset = numberdata.conversionset
+-- if conversionset then
+-- local conversion = getstructureset("structure:conversions",p.block,conversionset,1,"numbers")
+-- if conversion ~= lastconversion then
+-- lastconversion = conversion
+-- list[#list+1] = i - 1 -- pdf starts numbering at 0
+-- list[#list+1] = pdfdictionary { S = pdfconstant(map[conversion] or map.numbers) }
+-- end
+-- end
+-- end
+-- if not lastconversion then
+-- lastconversion = "numbers"
+-- list[#list+1] = i - 1 -- pdf starts numbering at 0
+-- list[#list+1] = pdfdictionary { S = pdfconstant(map.numbers) }
+-- end
+-- end
+-- end
+-- lpdf.addtocatalog("PageLabels", pdfdictionary { Nums = list })
+-- end
+
local function featurecreep()
- local pages, lastconversion, list = structures.pages.tobesaved, nil, pdfarray()
- local getstructureset = structures.sets.get
+ local pages = structures.pages.tobesaved
+ local list = pdfarray()
+ local getset = structures.sets.get
+ local stopped = false
+ local oldlabel = nil
+ local olconversion = nil
for i=1,#pages do
local p = pages[i]
if not p then
return -- fatal error
+ end
+ local label = p.viewerprefix or ""
+ if p.status == v_stop then
+ if not stopped then
+ list[#list+1] = i - 1 -- pdf starts numbering at 0
+ list[#list+1] = pdfdictionary {
+ P = pdfunicode(label),
+ }
+ stopped = true
+ end
+ oldlabel = nil
+ oldconversion = nil
+ stopped = false
else
local numberdata = p.numberdata
+ local conversion = nil
+ local number = p.number
if numberdata then
local conversionset = numberdata.conversionset
if conversionset then
- local conversion = getstructureset("structure:conversions",p.block,conversionset,1,"numbers")
- if conversion ~= lastconversion then
- lastconversion = conversion
- list[#list+1] = i - 1 -- pdf starts numbering at 0
- list[#list+1] = pdfdictionary { S = pdfconstant(map[conversion] or map.numbers) }
- end
+ conversion = getset("structure:conversions",p.block,conversionset,1,"numbers")
end
end
- if not lastconversion then
- lastconversion = "numbers"
+ conversion = conversion and map[conversion] or map.numbers
+ if number == 1 or oldlabel ~= label or oldconversion ~= conversion then
list[#list+1] = i - 1 -- pdf starts numbering at 0
- list[#list+1] = pdfdictionary { S = pdfconstant(map.numbers) }
+ list[#list+1] = pdfdictionary {
+ S = pdfconstant(conversion),
+ St = number,
+ P = label ~= "" and pdfunicode(label) or nil,
+ }
end
+ oldlabel = label
+ oldconversion = conversion
+ stopped = false
end
end
lpdf.addtocatalog("PageLabels", pdfdictionary { Nums = list })
diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua
index 4da1cded2..1351559a0 100644
--- a/tex/context/base/math-ini.lua
+++ b/tex/context/base/math-ini.lua
@@ -350,10 +350,12 @@ local utf8byte = lpeg.patterns.utf8byte * lpeg.P(-1)
local somechar = { }
table.setmetatableindex(somechar,function(t,k)
- local b = lpegmatch(utf8byte,k)
- local v = b and chardata[b] or false
- t[k] = v
- return v
+ if k then
+ local b = lpegmatch(utf8byte,k)
+ local v = b and chardata[b] or false
+ t[k] = v
+ return v
+ end
end)
local function utfmathclass(chr, default)
diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index 80fd14775..9206743f4 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -36,6 +36,7 @@
\def\c!fences {fences}
\def\c!keeptogether {keeptogether}
+\def\c!viewerprefix {viewerprefix}
\def\c!dataset {dataset}
\def\c!sectionblock {sectionblock}
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 299d73213..ae09bb5ae 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 e8ef5d9f1..8f1f3e5c8 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua
index 7b43a3a58..fd0a367aa 100644
--- a/tex/context/base/strc-pag.lua
+++ b/tex/context/base/strc-pag.lua
@@ -52,7 +52,7 @@ job.register('structures.pages.collected', tobesaved, initializer)
local specification = { } -- to be checked
-function pages.save(prefixdata,numberdata)
+function pages.save(prefixdata,numberdata,extradata)
local realpage = texgetcount("realpageno")
local userpage = texgetcount("userpageno")
if realpage > 0 then
@@ -60,10 +60,12 @@ function pages.save(prefixdata,numberdata)
report_pages("saving page %s.%s",realpage,userpage)
end
local data = {
- number = userpage,
- block = sections.currentblock(),
- prefixdata = prefixdata and helpers.simplify(prefixdata),
- numberdata = numberdata and helpers.simplify(numberdata),
+ number = userpage,
+ viewerprefix = extradata.viewerprefix,
+ state = extradata.state,
+ block = sections.currentblock(),
+ prefixdata = prefixdata and helpers.simplify(prefixdata),
+ numberdata = numberdata and helpers.simplify(numberdata),
}
tobesaved[realpage] = data
if not collected[realpage] then
diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv
index 85cfeb40f..c4e9819ba 100644
--- a/tex/context/base/strc-pag.mkiv
+++ b/tex/context/base/strc-pag.mkiv
@@ -106,6 +106,8 @@
\let\setuppagenumber\setupuserpagenumber
\let\resetpagenumber\resetuserpagenumber
+% invisible =
+
\def\strc_pagenumbers_page_state_save % \normalexpanded?
{\ctxlua{structures.pages.save({
prefix = "\namedcounterparameter\s!userpage\c!prefix",
@@ -120,6 +122,9 @@
conversionset = "\namedcounterparameter\s!userpage\c!numberconversionset",
starter = \!!bs\namedcounterparameter\s!userpage\c!numberstarter\!!es,
stopper = \!!bs\namedcounterparameter\s!userpage\c!numberstopper\!!es,
+ },{
+ viewerprefix = \!!bs\namedcounterparameter\s!userpage\c!viewerprefix\!!es,
+ state = \!!bs\namedcounterparameter\s!userpage\c!state\!!es,
}
)}}
diff --git a/tex/context/base/util-str.lua b/tex/context/base/util-str.lua
index f04f0e573..4ecaed7d3 100644
--- a/tex/context/base/util-str.lua
+++ b/tex/context/base/util-str.lua
@@ -20,16 +20,24 @@ local utfchar, utfbyte = utf.char, utf.byte
----- loadstripped = utilities.lua.loadstripped
----- setmetatableindex = table.setmetatableindex
--- local loadstripped = _LUAVERSION < 5.2 and load or function(str)
--- return load(dump(load(str),true)) -- it only makes sense in luajit and luatex where we have a stipped load
--- end
+local loadstripped = nil
-local loadstripped = function(str,shortcuts)
- if shortcuts then
- return load(dump(load(str),true),nil,nil,shortcuts)
- else
- return load(dump(load(str),true))
+if _LUAVERSION < 5.2 then
+
+ loadstripped = function(str,shortcuts)
+ return load(str)
+ end
+
+else
+
+ loadstripped = function(str,shortcuts)
+ if shortcuts then
+ return load(dump(load(str),true),nil,nil,shortcuts)
+ else
+ return load(dump(load(str),true))
+ end
end
+
end
-- todo: make a special namespace for the formatter
@@ -305,60 +313,58 @@ local template = [[
return function(%s) return %s end
]]
--- local environment = {
--- lpeg = lpeg,
--- type = type,
--- string = string,
--- number = number,
--- table = table,
--- utf = utf,
--- }
---
--- local preamble = [[
--- local type = type
--- local tostring = tostring
--- local tonumber = tonumber
--- local format = string.format
--- local concat = table.concat
--- local signed = number.signed
--- local points = number.points
--- local basepoints = number.basepoints
--- local utfchar = utf.char
--- local utfbyte = utf.byte
--- local lpegmatch = lpeg.match
--- local nspaces = string.nspaces
--- local tracedchar = string.tracedchar
--- local autosingle = string.autosingle
--- local autodouble = string.autodouble
--- local sequenced = table.sequenced
--- local formattednumber = number.formatted
--- local sparseexponent = number.sparseexponent
--- ]]
-
-local environment = {
- global = global or _G,
- lpeg = lpeg,
- type = type,
- tostring = tostring,
- tonumber = tonumber,
- format = string.format,
- concat = table.concat,
- signed = number.signed,
- points = number.points,
- basepoints = number.basepoints,
- utfchar = utf.char,
- utfbyte = utf.byte,
- lpegmatch = lpeg.match,
- nspaces = string.nspaces,
- tracedchar = string.tracedchar,
- autosingle = string.autosingle,
- autodouble = string.autodouble,
- sequenced = table.sequenced,
- formattednumber = number.formatted,
- sparseexponent = number.sparseexponent,
-}
+local preamble, environment = "", { }
+
+if _LUAVERSION < 5.2 then
+
+ preamble = [[
+local lpeg=lpeg
+local type=type
+local tostring=tostring
+local tonumber=tonumber
+local format=string.format
+local concat=table.concat
+local signed=number.signed
+local points=number.points
+local basepoints= number.basepoints
+local utfchar=utf.char
+local utfbyte=utf.byte
+local lpegmatch=lpeg.match
+local nspaces=string.nspaces
+local tracedchar=string.tracedchar
+local autosingle=string.autosingle
+local autodouble=string.autodouble
+local sequenced=table.sequenced
+local formattednumber=number.formatted
+local sparseexponent=number.sparseexponent
+ ]]
+
+else
+
+ environment = {
+ global = global or _G,
+ lpeg = lpeg,
+ type = type,
+ tostring = tostring,
+ tonumber = tonumber,
+ format = string.format,
+ concat = table.concat,
+ signed = number.signed,
+ points = number.points,
+ basepoints = number.basepoints,
+ utfchar = utf.char,
+ utfbyte = utf.byte,
+ lpegmatch = lpeg.match,
+ nspaces = string.nspaces,
+ tracedchar = string.tracedchar,
+ autosingle = string.autosingle,
+ autodouble = string.autodouble,
+ sequenced = table.sequenced,
+ formattednumber = number.formatted,
+ sparseexponent = number.sparseexponent,
+ }
-local preamble = ""
+end
-- -- --
@@ -869,14 +875,26 @@ strings.formatters = { }
-- table (metatable) in which case we could better keep a count and
-- clear that table when a threshold is reached
-function strings.formatters.new()
- local e = { } -- better make a copy as we can overload
- for k, v in next, environment do
- e[k] = v
+if _LUAVERSION < 5.2 then
+
+ function strings.formatters.new()
+ local t = { _extensions_ = { }, _preamble_ = preamble, _environment_ = { }, _type_ = "formatter" }
+ setmetatable(t, { __index = make, __call = use })
+ return t
end
- local t = { _extensions_ = { }, _preamble_ = "", _environment_ = e, _type_ = "formatter" }
- setmetatable(t, { __index = make, __call = use })
- return t
+
+else
+
+ function strings.formatters.new()
+ local e = { } -- better make a copy as we can overload
+ for k, v in next, environment do
+ e[k] = v
+ end
+ local t = { _extensions_ = { }, _preamble_ = "", _environment_ = e, _type_ = "formatter" }
+ setmetatable(t, { __index = make, __call = use })
+ return t
+ end
+
end
-- function strings.formatters.new()
@@ -921,9 +939,19 @@ patterns.luaquoted = Cs(Cc('"') * ((1-S('"\n'))^1 + P('"')/'\\"' + P('\n')/'\\n"
-- add(formatters,"tex", [[lpegmatch(texescape,%s)]],[[local texescape = lpeg.patterns.texescape]])
-- add(formatters,"lua", [[lpegmatch(luaescape,%s)]],[[local luaescape = lpeg.patterns.luaescape]])
-add(formatters,"xml", [[lpegmatch(xmlescape,%s)]],{ xmlescape = lpeg.patterns.xmlescape })
-add(formatters,"tex", [[lpegmatch(texescape,%s)]],{ texescape = lpeg.patterns.texescape })
-add(formatters,"lua", [[lpegmatch(luaescape,%s)]],{ luaescape = lpeg.patterns.luaescape })
+if _LUAVERSION < 5.2 then
+
+ add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape")
+ add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape")
+ add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape")
+
+else
+
+ add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape = lpeg.patterns.xmlescape })
+ add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape = lpeg.patterns.texescape })
+ add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape = lpeg.patterns.luaescape })
+
+end
-- -- yes or no:
--
diff --git a/tex/context/base/util-tab.lua b/tex/context/base/util-tab.lua
index ae44269bb..d235520c4 100644
--- a/tex/context/base/util-tab.lua
+++ b/tex/context/base/util-tab.lua
@@ -316,7 +316,7 @@ function table.fastserialize(t,prefix)
-- not sorted
-- only number and string indices (currently)
- local r = { prefix or "return" }
+ local r = { type(prefix) == "string" and prefix or "return" }
local m = 1
local function fastserialize(t,outer) -- no mixes
@@ -376,7 +376,6 @@ function table.fastserialize(t,prefix)
end
return r
end
-
return concat(fastserialize(t,true))
end
diff --git a/tex/context/base/x-mathml.lua b/tex/context/base/x-mathml.lua
index e2bb62d12..baf839ad8 100644
--- a/tex/context/base/x-mathml.lua
+++ b/tex/context/base/x-mathml.lua
@@ -82,8 +82,9 @@ local o_replacements = { -- in main table
-- [utfchar(0xF103C)] = "\\mmlleftdelimiter<",
[utfchar(0xF1026)] = "\\mmlchar{38}",
+ [utfchar(0x02061)] = "", -- function applicator sometimes shows up in font
-- [utfchar(0xF103E)] = "\\mmlleftdelimiter>",
--- [utfchar(0xAF)] = '\\mmlchar{"203E}', -- 0x203E
+ -- [utfchar(0x000AF)] = '\\mmlchar{"203E}', -- 0x203E
}
local simpleoperatorremapper = utf.remapper(o_replacements)
diff --git a/tex/context/base/x-mathml.mkiv b/tex/context/base/x-mathml.mkiv
index 320d19251..5520dbbe6 100644
--- a/tex/context/base/x-mathml.mkiv
+++ b/tex/context/base/x-mathml.mkiv
@@ -2295,7 +2295,7 @@
} {
\edef\mmlbasecommand{\utfmathfiller\mmlbasetoken}
\edef\mmlovercommand{\utfmathfiller\mmlovertoken}
- \mmlovertriplet{\mmloveros{#1}}{\mmloverbf{#1}}\relax
+ \mmlundertriplet{\mmloverbf{#1}}{\mmloveros{#1}}{}%\relax
}
}
% \limits % spoils spacing
@@ -2344,7 +2344,7 @@
} {
\edef\mmlbasecommand {\utfmathfiller\mmlbasetoken}
\edef\mmlundercommand{\utfmathfiller\mmlundertoken}
- \mmlundertriplet{\mmlunderus{#1}}{\mmlunderbf{#1}}\relax
+ \mmlundertriplet{\mmlunderbf{#1}}{}{\mmlunderus{#1}}%\relax
}
}
% \limits % spoils spacing
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index d475be6d7..3f408b96f 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 : 02/13/14 11:27:58
+-- merge date : 02/14/14 17:07:59
do -- begin closure to overcome local limits and interference
@@ -82,7 +82,9 @@ function optionalrequire(...)
return result
end
end
-lua.mask=load([[τεχ = 1]]) and "utf" or "ascii"
+if lua then
+ lua.mask=load([[τεχ = 1]]) and "utf" or "ascii"
+end
end -- closure
@@ -2523,11 +2525,18 @@ local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte=utf.char,utf.byte
-local loadstripped=function(str,shortcuts)
- if shortcuts then
- return load(dump(load(str),true),nil,nil,shortcuts)
- else
- return load(dump(load(str),true))
+local loadstripped=nil
+if _LUAVERSION<5.2 then
+ loadstripped=function(str,shortcuts)
+ return load(str)
+ end
+else
+ loadstripped=function(str,shortcuts)
+ if shortcuts then
+ return load(dump(load(str),true),nil,nil,shortcuts)
+ else
+ return load(dump(load(str),true))
+ end
end
end
if not number then number={} end
@@ -2683,29 +2692,53 @@ local template=[[
%s
return function(%s) return %s end
]]
-local environment={
- global=global or _G,
- lpeg=lpeg,
- type=type,
- tostring=tostring,
- tonumber=tonumber,
- format=string.format,
- concat=table.concat,
- signed=number.signed,
- points=number.points,
- basepoints=number.basepoints,
- utfchar=utf.char,
- utfbyte=utf.byte,
- lpegmatch=lpeg.match,
- nspaces=string.nspaces,
- tracedchar=string.tracedchar,
- autosingle=string.autosingle,
- autodouble=string.autodouble,
- sequenced=table.sequenced,
- formattednumber=number.formatted,
- sparseexponent=number.sparseexponent,
-}
-local preamble=""
+local preamble,environment="",{}
+if _LUAVERSION<5.2 then
+ preamble=[[
+local lpeg=lpeg
+local type=type
+local tostring=tostring
+local tonumber=tonumber
+local format=string.format
+local concat=table.concat
+local signed=number.signed
+local points=number.points
+local basepoints= number.basepoints
+local utfchar=utf.char
+local utfbyte=utf.byte
+local lpegmatch=lpeg.match
+local nspaces=string.nspaces
+local tracedchar=string.tracedchar
+local autosingle=string.autosingle
+local autodouble=string.autodouble
+local sequenced=table.sequenced
+local formattednumber=number.formatted
+local sparseexponent=number.sparseexponent
+ ]]
+else
+ environment={
+ global=global or _G,
+ lpeg=lpeg,
+ type=type,
+ tostring=tostring,
+ tonumber=tonumber,
+ format=string.format,
+ concat=table.concat,
+ signed=number.signed,
+ points=number.points,
+ basepoints=number.basepoints,
+ utfchar=utf.char,
+ utfbyte=utf.byte,
+ lpegmatch=lpeg.match,
+ nspaces=string.nspaces,
+ tracedchar=string.tracedchar,
+ autosingle=string.autosingle,
+ autodouble=string.autodouble,
+ sequenced=table.sequenced,
+ formattednumber=number.formatted,
+ sparseexponent=number.sparseexponent,
+ }
+end
local arguments={ "a1" }
setmetatable(arguments,{ __index=function(t,k)
local v=t[k-1]..",a"..k
@@ -3052,14 +3085,22 @@ local function use(t,fmt,...)
return t[fmt](...)
end
strings.formatters={}
-function strings.formatters.new()
- local e={}
- for k,v in next,environment do
- e[k]=v
+if _LUAVERSION<5.2 then
+ function strings.formatters.new()
+ local t={ _extensions_={},_preamble_=preamble,_environment_={},_type_="formatter" }
+ setmetatable(t,{ __index=make,__call=use })
+ return t
+ end
+else
+ function strings.formatters.new()
+ local e={}
+ for k,v in next,environment do
+ e[k]=v
+ end
+ local t={ _extensions_={},_preamble_="",_environment_=e,_type_="formatter" }
+ setmetatable(t,{ __index=make,__call=use })
+ return t
end
- local t={ _extensions_={},_preamble_="",_environment_=e,_type_="formatter" }
- setmetatable(t,{ __index=make,__call=use })
- return t
end
local formatters=strings.formatters.new()
string.formatters=formatters
@@ -3081,9 +3122,15 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+P(1))^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+if _LUAVERSION<5.2 then
+ add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],"local xmlescape = lpeg.patterns.xmlescape")
+ add(formatters,"tex",[[lpegmatch(texescape,%s)]],"local texescape = lpeg.patterns.texescape")
+ add(formatters,"lua",[[lpegmatch(luaescape,%s)]],"local luaescape = lpeg.patterns.luaescape")
+else
+ add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
+ add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
+ add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+end
end -- closure