diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-06-08 12:19:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-06-08 12:19:55 +0000 |
commit | 7d4d7bd57d826a9576318a3e8f1db50188764566 (patch) | |
tree | 2336337a3561087d91ffefa47a4366d3a4cac3a2 /Master/texmf-dist | |
parent | 4809fa94a8d42936d46320477ce193190987f4d4 (diff) |
ConTeXt 2012.05.30 11:26
git-svn-id: svn://tug.org/texlive/trunk@26861 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
21 files changed, 422 insertions, 43 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtxrun.lua b/Master/texmf-dist/scripts/context/lua/mtxrun.lua index d2f7e408f0d..108f2a8a112 100755 --- a/Master/texmf-dist/scripts/context/lua/mtxrun.lua +++ b/Master/texmf-dist/scripts/context/lua/mtxrun.lua @@ -4087,8 +4087,10 @@ local one = P(1) local two = C(1) * C(1) local four = C(R(utfchar(0xD8),utfchar(0xFF))) * C(1) * C(1) * C(1) +-- actually one of them is already utf ... sort of useless this one + local pattern = P("\254\255") * Cs( ( - four / function(a,b,c,d) + four / function(a,b,c,d) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -4099,7 +4101,7 @@ local pattern = P("\254\255") * Cs( ( + one )^1 ) + P("\255\254") * Cs( ( - four / function(b,a,d,c) + four / function(b,a,d,c) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -4114,6 +4116,22 @@ function string.toutf(s) return lpegmatch(pattern,s) or s -- todo: utf32 end +local validatedutf = Cs ( + ( + patterns.utf8one + + patterns.utf8two + + patterns.utf8three + + patterns.utf8four + + P(1) / "�" + )^0 +) + +patterns.validatedutf = validatedutf + +function string.validutf(str) + return lpegmatch(validatedutf,str) +end + end -- of closure @@ -8174,6 +8192,34 @@ function xml.makestandalone(root) return root end +function xml.kind(e) + local dt = e and e.dt + if dt then + local n = #dt + if n == 1 then + local d = dt[1] + if d.special then + local tg = d.tg + if tg == "@cd@" then + return "cdata" + elseif tg == "@cm" then + return "comment" + elseif tg == "@pi@" then + return "instruction" + elseif tg == "@dt@" then + return "declaration" + end + elseif type(d) == "string" then + return "text" + end + return "element" + elseif n > 0 then + return "mixed" + end + end + return "empty" +end + end -- of closure @@ -9601,7 +9647,7 @@ local xmlfilter = xml.filter local type, setmetatable, getmetatable = type, setmetatable, getmetatable local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat -local gmatch, gsub, format = string.gmatch, string.gsub, string.format +local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.format, string.find, string.strip local utfbyte = utf.byte local function report(what,pattern,c,e) @@ -10293,6 +10339,51 @@ function xml.setcdata(e,str) -- also setcomment } } end +-- maybe helpers like this will move to an autoloader + +function xml.separate(x,pattern) + local collected = xmlapplylpath(x,pattern) + if collected then + for c=1,#collected do + local e = collected[c] + local d = e.dt + if d == x then + report_xml("warning: xml.separate changes root") + x = d + end + local t, n = { "\n" }, 1 + local i, nd = 1, #d + while i <= nd do + while i <= nd do + local di = d[i] + if type(di) == "string" then + if di == "\n" or find(di,"^%s+$") then -- first test is speedup + i = i + 1 + else + d[i] = strip(di) + break + end + else + break + end + end + if i > nd then + break + end + t[n+1] = "\n" + t[n+2] = d[i] + t[n+3] = "\n" + n = n + 3 + i = i + 1 + end + t[n+1] = "\n" + setmetatable(t,getmetatable(d)) + e.dt = t + end + end + return x +end + end -- of closure diff --git a/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua b/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua index d2f7e408f0d..108f2a8a112 100644 --- a/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua +++ b/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua @@ -4087,8 +4087,10 @@ local one = P(1) local two = C(1) * C(1) local four = C(R(utfchar(0xD8),utfchar(0xFF))) * C(1) * C(1) * C(1) +-- actually one of them is already utf ... sort of useless this one + local pattern = P("\254\255") * Cs( ( - four / function(a,b,c,d) + four / function(a,b,c,d) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -4099,7 +4101,7 @@ local pattern = P("\254\255") * Cs( ( + one )^1 ) + P("\255\254") * Cs( ( - four / function(b,a,d,c) + four / function(b,a,d,c) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -4114,6 +4116,22 @@ function string.toutf(s) return lpegmatch(pattern,s) or s -- todo: utf32 end +local validatedutf = Cs ( + ( + patterns.utf8one + + patterns.utf8two + + patterns.utf8three + + patterns.utf8four + + P(1) / "�" + )^0 +) + +patterns.validatedutf = validatedutf + +function string.validutf(str) + return lpegmatch(validatedutf,str) +end + end -- of closure @@ -8174,6 +8192,34 @@ function xml.makestandalone(root) return root end +function xml.kind(e) + local dt = e and e.dt + if dt then + local n = #dt + if n == 1 then + local d = dt[1] + if d.special then + local tg = d.tg + if tg == "@cd@" then + return "cdata" + elseif tg == "@cm" then + return "comment" + elseif tg == "@pi@" then + return "instruction" + elseif tg == "@dt@" then + return "declaration" + end + elseif type(d) == "string" then + return "text" + end + return "element" + elseif n > 0 then + return "mixed" + end + end + return "empty" +end + end -- of closure @@ -9601,7 +9647,7 @@ local xmlfilter = xml.filter local type, setmetatable, getmetatable = type, setmetatable, getmetatable local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat -local gmatch, gsub, format = string.gmatch, string.gsub, string.format +local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.format, string.find, string.strip local utfbyte = utf.byte local function report(what,pattern,c,e) @@ -10293,6 +10339,51 @@ function xml.setcdata(e,str) -- also setcomment } } end +-- maybe helpers like this will move to an autoloader + +function xml.separate(x,pattern) + local collected = xmlapplylpath(x,pattern) + if collected then + for c=1,#collected do + local e = collected[c] + local d = e.dt + if d == x then + report_xml("warning: xml.separate changes root") + x = d + end + local t, n = { "\n" }, 1 + local i, nd = 1, #d + while i <= nd do + while i <= nd do + local di = d[i] + if type(di) == "string" then + if di == "\n" or find(di,"^%s+$") then -- first test is speedup + i = i + 1 + else + d[i] = strip(di) + break + end + else + break + end + end + if i > nd then + break + end + t[n+1] = "\n" + t[n+2] = d[i] + t[n+3] = "\n" + n = n + 3 + i = i + 1 + end + t[n+1] = "\n" + setmetatable(t,getmetatable(d)) + e.dt = t + end + end + return x +end + end -- of closure diff --git a/Master/texmf-dist/scripts/context/stubs/unix/mtxrun b/Master/texmf-dist/scripts/context/stubs/unix/mtxrun index d2f7e408f0d..108f2a8a112 100755 --- a/Master/texmf-dist/scripts/context/stubs/unix/mtxrun +++ b/Master/texmf-dist/scripts/context/stubs/unix/mtxrun @@ -4087,8 +4087,10 @@ local one = P(1) local two = C(1) * C(1) local four = C(R(utfchar(0xD8),utfchar(0xFF))) * C(1) * C(1) * C(1) +-- actually one of them is already utf ... sort of useless this one + local pattern = P("\254\255") * Cs( ( - four / function(a,b,c,d) + four / function(a,b,c,d) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -4099,7 +4101,7 @@ local pattern = P("\254\255") * Cs( ( + one )^1 ) + P("\255\254") * Cs( ( - four / function(b,a,d,c) + four / function(b,a,d,c) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -4114,6 +4116,22 @@ function string.toutf(s) return lpegmatch(pattern,s) or s -- todo: utf32 end +local validatedutf = Cs ( + ( + patterns.utf8one + + patterns.utf8two + + patterns.utf8three + + patterns.utf8four + + P(1) / "�" + )^0 +) + +patterns.validatedutf = validatedutf + +function string.validutf(str) + return lpegmatch(validatedutf,str) +end + end -- of closure @@ -8174,6 +8192,34 @@ function xml.makestandalone(root) return root end +function xml.kind(e) + local dt = e and e.dt + if dt then + local n = #dt + if n == 1 then + local d = dt[1] + if d.special then + local tg = d.tg + if tg == "@cd@" then + return "cdata" + elseif tg == "@cm" then + return "comment" + elseif tg == "@pi@" then + return "instruction" + elseif tg == "@dt@" then + return "declaration" + end + elseif type(d) == "string" then + return "text" + end + return "element" + elseif n > 0 then + return "mixed" + end + end + return "empty" +end + end -- of closure @@ -9601,7 +9647,7 @@ local xmlfilter = xml.filter local type, setmetatable, getmetatable = type, setmetatable, getmetatable local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat -local gmatch, gsub, format = string.gmatch, string.gsub, string.format +local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.format, string.find, string.strip local utfbyte = utf.byte local function report(what,pattern,c,e) @@ -10293,6 +10339,51 @@ function xml.setcdata(e,str) -- also setcomment } } end +-- maybe helpers like this will move to an autoloader + +function xml.separate(x,pattern) + local collected = xmlapplylpath(x,pattern) + if collected then + for c=1,#collected do + local e = collected[c] + local d = e.dt + if d == x then + report_xml("warning: xml.separate changes root") + x = d + end + local t, n = { "\n" }, 1 + local i, nd = 1, #d + while i <= nd do + while i <= nd do + local di = d[i] + if type(di) == "string" then + if di == "\n" or find(di,"^%s+$") then -- first test is speedup + i = i + 1 + else + d[i] = strip(di) + break + end + else + break + end + end + if i > nd then + break + end + t[n+1] = "\n" + t[n+2] = d[i] + t[n+3] = "\n" + n = n + 3 + i = i + 1 + end + t[n+1] = "\n" + setmetatable(t,getmetatable(d)) + e.dt = t + end + end + return x +end + end -- of closure diff --git a/Master/texmf-dist/tex/context/base/buff-imp-mp.lua b/Master/texmf-dist/tex/context/base/buff-imp-mp.lua index f219df79753..34e3459c6e9 100644 --- a/Master/texmf-dist/tex/context/base/buff-imp-mp.lua +++ b/Master/texmf-dist/tex/context/base/buff-imp-mp.lua @@ -13,6 +13,14 @@ if not modules then modules = { } end modules ['buff-imp-mp'] = { -- the rendering and have a different way of nesting. It is no coincidence -- that the coloring looks similar: both are derived from earlier lexing (in -- texedit, mkii and the c++ scite lexer). +-- +-- In the meantime we have lpeg based lexers in scite! And, as all this +-- lexing boils down to the same principles (associating symbolic rendering +-- with ranges of characters) and as the scite lexers do nesting, it makes +-- sense at some point to share code. However, keep in mind that the pretty +-- printers are also supposed to support invalid code (for educational +-- purposes). The scite lexers are more recent and there a different color +-- scheme is used. So, we might move away from the traditional coloring. local P, S, V, patterns = lpeg.P, lpeg.S, lpeg.V, lpeg.patterns diff --git a/Master/texmf-dist/tex/context/base/buff-imp-xml.lua b/Master/texmf-dist/tex/context/base/buff-imp-xml.lua index baf290d4ce7..0c48ed3b090 100644 --- a/Master/texmf-dist/tex/context/base/buff-imp-xml.lua +++ b/Master/texmf-dist/tex/context/base/buff-imp-xml.lua @@ -99,11 +99,11 @@ local grammar = visualizers.newgrammar("default", { "visualizer", * makepattern(handler,"boundary",closeend), comment = makepattern(handler,"boundary",opencomment) - * (V("whitespace") + makepattern(handler,"comment",(1-closecomment)))^0 -- slow + * (V("whitespace") + makepattern(handler,"comment",(1-closecomment)^1))^0 -- slow * makepattern(handler,"boundary",closecomment), cdata = makepattern(handler,"boundary",opencdata) - * (V("whitespace") + makepattern(handler,"comment",(1-closecdata)))^0 -- slow + * (V("whitespace") + makepattern(handler,"comment",(1-closecdata)^1))^0 -- slow * makepattern(handler,"boundary",closecdata), instruction = makepattern(handler,"boundary",openinstruction) diff --git a/Master/texmf-dist/tex/context/base/chem-str.lua b/Master/texmf-dist/tex/context/base/chem-str.lua index 6e2af50fb4b..fb325ccea9f 100644 --- a/Master/texmf-dist/tex/context/base/chem-str.lua +++ b/Master/texmf-dist/tex/context/base/chem-str.lua @@ -293,18 +293,18 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) if set then for i=1,#set do local si = set[i] - m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\dochemicaltext{%s}");',operation,bonds,si,si) + m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,si,si) end elseif upto then for i=index,upto do local si = set[i] - m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\dochemicaltext{%s}");',operation,bonds,si,si) + m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,si,si) end elseif index then - m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\dochemicaltext{%s}");',operation,bonds,index,index) + m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,index,index) else for i=1,max do - m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\dochemicaltext{%s}");',operation,bonds,i,i) + m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,i,i) end end elseif what == "text" then @@ -320,7 +320,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) local a = align and align[si] if a then a = "." .. a else a = "" end t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,a,bonds,si,t) + m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\chemicaltext{%s}");',operation,a,bonds,si,t) end end elseif upto then @@ -331,7 +331,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) local s = align and align[i] if s then s = "." .. s else s = "" end t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,i,t) + m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\chemicaltext{%s}");',operation,s,bonds,i,t) end end elseif index == 0 then @@ -339,7 +339,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) if not t then txt, t = fetch(txt) end if t then t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s_zero("\\dochemicaltext{%s}");',operation,t) + m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) end elseif index then local t = text @@ -348,7 +348,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) local s = align and align[index] if s then s = "." .. s else s = "" end t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,index,t) + m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\chemicaltext{%s}");',operation,s,bonds,index,t) end else for i=1,max do @@ -358,7 +358,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) local s = align and align[i] if s then s = "." .. s else s = "" end t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,i,t) + m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\chemicaltext{%s}");',operation,s,bonds,i,t) end end end diff --git a/Master/texmf-dist/tex/context/base/chem-str.mkiv b/Master/texmf-dist/tex/context/base/chem-str.mkiv index e74c268da68..1d60a293efc 100644 --- a/Master/texmf-dist/tex/context/base/chem-str.mkiv +++ b/Master/texmf-dist/tex/context/base/chem-str.mkiv @@ -99,12 +99,12 @@ \edef\chemicaltoplocation{t} \edef\chemicalbotlocation{b} -\def\chem_text#1% in ppchtex we had a more clever alignment - {\usechemicalstyleandcolor\c!style\c!color - \strut - #1} % maybe also \setstrut +% \unexpanded\def\chemicaltext#1% in ppchtex we had a more clever alignment +% {\usechemicalstyleandcolor\c!style\c!color +% \strut +% #1} % maybe also \setstrut -\def\chem_text#1% +\unexpanded\def\chemicaltext#1% {\mathematics {\usechemicalstyleandcolor\c!style\c!color \strut diff --git a/Master/texmf-dist/tex/context/base/cont-new.mkii b/Master/texmf-dist/tex/context/base/cont-new.mkii index eddc0890c5e..b4958762f1a 100644 --- a/Master/texmf-dist/tex/context/base/cont-new.mkii +++ b/Master/texmf-dist/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.05.29 00:12} +\newcontextversion{2012.05.30 11:26} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/Master/texmf-dist/tex/context/base/cont-new.mkiv b/Master/texmf-dist/tex/context/base/cont-new.mkiv index 8c514cbfd61..5a28f8e29ff 100644 --- a/Master/texmf-dist/tex/context/base/cont-new.mkiv +++ b/Master/texmf-dist/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.05.29 00:12} +\newcontextversion{2012.05.30 11:26} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/Master/texmf-dist/tex/context/base/context-version.pdf b/Master/texmf-dist/tex/context/base/context-version.pdf Binary files differindex da774042753..7b8733c8827 100644 --- a/Master/texmf-dist/tex/context/base/context-version.pdf +++ b/Master/texmf-dist/tex/context/base/context-version.pdf diff --git a/Master/texmf-dist/tex/context/base/context-version.png b/Master/texmf-dist/tex/context/base/context-version.png Binary files differindex 821f60efc4f..bb280817c4f 100644 --- a/Master/texmf-dist/tex/context/base/context-version.png +++ b/Master/texmf-dist/tex/context/base/context-version.png diff --git a/Master/texmf-dist/tex/context/base/context.mkii b/Master/texmf-dist/tex/context/base/context.mkii index 5923624a068..8cd02fd9e94 100644 --- a/Master/texmf-dist/tex/context/base/context.mkii +++ b/Master/texmf-dist/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.05.29 00:12} +\edef\contextversion{2012.05.30 11:26} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/context.mkiv b/Master/texmf-dist/tex/context/base/context.mkiv index f4da94ef16f..5044edae138 100644 --- a/Master/texmf-dist/tex/context/base/context.mkiv +++ b/Master/texmf-dist/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.05.29 00:12} +\edef\contextversion{2012.05.30 11:26} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/font-emp.mkvi b/Master/texmf-dist/tex/context/base/font-emp.mkvi index 65aa7a52074..1713eda7051 100644 --- a/Master/texmf-dist/tex/context/base/font-emp.mkvi +++ b/Master/texmf-dist/tex/context/base/font-emp.mkvi @@ -218,6 +218,10 @@ \unexpanded\def\emphsl{\groupedcommand{\sl\def\emphbf{\bs}\def\emphit{\it}}{}} \unexpanded\def\emphtf{\groupedcommand{\tf\def\emphbf{\bf}\def\emphit{\it}\def\emphsl{\sl}}{}} +\unexpanded\def\emph {\groupedcommand{\em}{}} + +\unexpanded\def\emphasized{\bgroup\em\let\nexttoken} + %D \startbuffer %D TEXT {\emphbf text \emphit text \emphtf text \emphsl text} TEXT %D TEXT \emphbf{text \emphit{text} \emphtf{text} \emphsl{text}} TEXT diff --git a/Master/texmf-dist/tex/context/base/grph-trf.mkiv b/Master/texmf-dist/tex/context/base/grph-trf.mkiv index a33e5606dd8..5984c8a0630 100644 --- a/Master/texmf-dist/tex/context/base/grph-trf.mkiv +++ b/Master/texmf-dist/tex/context/base/grph-trf.mkiv @@ -38,6 +38,7 @@ \newconditional\c_grph_scale_done \newconditional\c_grph_scale_scaling_done +\newconditional\c_grph_scale_limit_factors \settrue\c_grph_scale_limit_factors \newdimen\d_grph_scale_wd \newdimen\d_grph_scale_ht @@ -232,14 +233,14 @@ % final values \global\d_grph_scale_used_x_size \zeropoint % see note * (core-fig) \global\d_grph_scale_used_y_size \zeropoint % see note * (core-fig) - \c_grph_scale_used_x_scale \plusone % see note * (core-fig) - \c_grph_scale_used_y_scale \plusone % see note * (core-fig) + \c_grph_scale_used_x_scale \plusone % see note * (core-fig) + \c_grph_scale_used_y_scale \plusone % see note * (core-fig) % preparations \setfalse\c_grph_scale_scaling_done \grph_scale_check_parameters % calculators % beware, they operate in sequence, and calculate missing dimensions / messy - %setscaleboxbynature % when? needed? + %grph_scale_by_nature % when? needed? \ifconditional\c_grph_scale_scaling_done\else\grph_scale_by_factor \fi \ifconditional\c_grph_scale_scaling_done\else\grph_scale_by_scale \fi \ifconditional\c_grph_scale_scaling_done\else\grph_scale_by_dimension\fi @@ -321,13 +322,15 @@ \def\grph_scale_by_factor_indeed {\settrue\c_grph_scale_scaling_done - \ifdim\d_grph_scale_used_x_size>\d_grph_scale_h_size - \global\d_grph_scale_used_y_size\zeropoint - \global\d_grph_scale_used_x_size\d_grph_scale_h_size - \else\ifdim\d_grph_scale_used_y_size>\d_grph_scale_v_size - \global\d_grph_scale_used_x_size\zeropoint - \global\d_grph_scale_used_y_size\d_grph_scale_v_size - \fi\fi + \ifconditional\c_grph_scale_limit_factors + \ifdim\d_grph_scale_used_x_size>\d_grph_scale_h_size + \global\d_grph_scale_used_y_size\zeropoint + \global\d_grph_scale_used_x_size\d_grph_scale_h_size + \else\ifdim\d_grph_scale_used_y_size>\d_grph_scale_v_size + \global\d_grph_scale_used_x_size\zeropoint + \global\d_grph_scale_used_y_size\d_grph_scale_v_size + \fi\fi + \fi \grph_scale_by_dimension} \def\grph_scale_by_scale diff --git a/Master/texmf-dist/tex/context/base/l-unicode.lua b/Master/texmf-dist/tex/context/base/l-unicode.lua index 246171aecc6..f4480e93c40 100644 --- a/Master/texmf-dist/tex/context/base/l-unicode.lua +++ b/Master/texmf-dist/tex/context/base/l-unicode.lua @@ -437,8 +437,10 @@ local one = P(1) local two = C(1) * C(1) local four = C(R(utfchar(0xD8),utfchar(0xFF))) * C(1) * C(1) * C(1) +-- actually one of them is already utf ... sort of useless this one + local pattern = P("\254\255") * Cs( ( - four / function(a,b,c,d) + four / function(a,b,c,d) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -449,7 +451,7 @@ local pattern = P("\254\255") * Cs( ( + one )^1 ) + P("\255\254") * Cs( ( - four / function(b,a,d,c) + four / function(b,a,d,c) local ab = 0xFF * byte(a) + byte(b) local cd = 0xFF * byte(c) + byte(d) return utfchar((ab-0xD800)*0x400 + (cd-0xDC00) + 0x10000) @@ -463,3 +465,19 @@ local pattern = P("\254\255") * Cs( ( function string.toutf(s) return lpegmatch(pattern,s) or s -- todo: utf32 end + +local validatedutf = Cs ( + ( + patterns.utf8one + + patterns.utf8two + + patterns.utf8three + + patterns.utf8four + + P(1) / "�" + )^0 +) + +patterns.validatedutf = validatedutf + +function string.validutf(str) + return lpegmatch(validatedutf,str) +end diff --git a/Master/texmf-dist/tex/context/base/lxml-aux.lua b/Master/texmf-dist/tex/context/base/lxml-aux.lua index 09411bfc0d5..be12659ba10 100644 --- a/Master/texmf-dist/tex/context/base/lxml-aux.lua +++ b/Master/texmf-dist/tex/context/base/lxml-aux.lua @@ -22,7 +22,7 @@ local xmlfilter = xml.filter local type, setmetatable, getmetatable = type, setmetatable, getmetatable local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat -local gmatch, gsub, format = string.gmatch, string.gsub, string.format +local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.format, string.find, string.strip local utfbyte = utf.byte local function report(what,pattern,c,e) @@ -721,3 +721,48 @@ function xml.setcdata(e,str) -- also setcomment dt = { str }, } } end + +-- maybe helpers like this will move to an autoloader + +function xml.separate(x,pattern) + local collected = xmlapplylpath(x,pattern) + if collected then + for c=1,#collected do + local e = collected[c] + local d = e.dt + if d == x then + report_xml("warning: xml.separate changes root") + x = d + end + local t, n = { "\n" }, 1 + local i, nd = 1, #d + while i <= nd do + while i <= nd do + local di = d[i] + if type(di) == "string" then + if di == "\n" or find(di,"^%s+$") then -- first test is speedup + i = i + 1 + else + d[i] = strip(di) + break + end + else + break + end + end + if i > nd then + break + end + t[n+1] = "\n" + t[n+2] = d[i] + t[n+3] = "\n" + n = n + 3 + i = i + 1 + end + t[n+1] = "\n" + setmetatable(t,getmetatable(d)) + e.dt = t + end + end + return x +end diff --git a/Master/texmf-dist/tex/context/base/lxml-tab.lua b/Master/texmf-dist/tex/context/base/lxml-tab.lua index fddd55a0971..b5c86078747 100644 --- a/Master/texmf-dist/tex/context/base/lxml-tab.lua +++ b/Master/texmf-dist/tex/context/base/lxml-tab.lua @@ -1338,3 +1338,31 @@ function xml.makestandalone(root) end return root end + +function xml.kind(e) + local dt = e and e.dt + if dt then + local n = #dt + if n == 1 then + local d = dt[1] + if d.special then + local tg = d.tg + if tg == "@cd@" then + return "cdata" + elseif tg == "@cm" then + return "comment" + elseif tg == "@pi@" then + return "instruction" + elseif tg == "@dt@" then + return "declaration" + end + elseif type(d) == "string" then + return "text" + end + return "element" + elseif n > 0 then + return "mixed" + end + end + return "empty" +end diff --git a/Master/texmf-dist/tex/context/base/status-files.pdf b/Master/texmf-dist/tex/context/base/status-files.pdf Binary files differindex e0233d26221..8d2ac58573f 100644 --- a/Master/texmf-dist/tex/context/base/status-files.pdf +++ b/Master/texmf-dist/tex/context/base/status-files.pdf diff --git a/Master/texmf-dist/tex/context/base/status-lua.pdf b/Master/texmf-dist/tex/context/base/status-lua.pdf Binary files differindex 95b9c543ca4..0d58d1b16fd 100644 --- a/Master/texmf-dist/tex/context/base/status-lua.pdf +++ b/Master/texmf-dist/tex/context/base/status-lua.pdf diff --git a/Master/texmf-dist/tex/generic/context/luatex/luatex-fonts-merged.lua b/Master/texmf-dist/tex/generic/context/luatex/luatex-fonts-merged.lua index d17e6d463b5..ea509c3386b 100644 --- a/Master/texmf-dist/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/Master/texmf-dist/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 : 05/29/12 00:12:55 +-- merge date : 05/30/12 11:26:34 do -- begin closure to overcome local limits and interference |