diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/char-ent.lua | 1 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4069 -> 4076 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 106603 -> 106472 bytes | |||
-rw-r--r-- | tex/context/base/data-lua.lua | 11 | ||||
-rw-r--r-- | tex/context/base/lxml-aux.lua | 75 | ||||
-rw-r--r-- | tex/context/base/lxml-tab.lua | 17 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 23980 -> 23978 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 168096 -> 168569 bytes | |||
-rw-r--r-- | tex/context/base/tabl-tsp.mkiv | 16 |
9 files changed, 104 insertions, 16 deletions
diff --git a/tex/context/base/char-ent.lua b/tex/context/base/char-ent.lua index c330d81a4..d2ac22bbf 100644 --- a/tex/context/base/char-ent.lua +++ b/tex/context/base/char-ent.lua @@ -2255,4 +2255,3 @@ characters.entities = entities entities.plusminus = "±" -- 0x000B1 entities.minusplus = "∓" -- 0x02213 entities.cdots = utf.char(0x02026) -- U+02026 - diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 6c5e32cec..bcb7a8077 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 9a62129e0..48d8de8b0 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/data-lua.lua b/tex/context/base/data-lua.lua index 065714407..906a611ee 100644 --- a/tex/context/base/data-lua.lua +++ b/tex/context/base/data-lua.lua @@ -78,8 +78,15 @@ local function loaded(libpaths,name,simple) end package.loaders[2] = function(name) -- was [#package.loaders+1] - if trace_locating then -- mode detail - report_libraries("! locating '%s'",name) + if file.suffix(name) == "" then + name = file.addsuffix(name,"lua") -- maybe a list + if trace_locating then -- mode detail + report_libraries("! locating '%s' with forced suffix",name) + end + else + if trace_locating then -- mode detail + report_libraries("! locating '%s'",name) + end end for i=1,#libformats do local format = libformats[i] diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua index 4798fe06a..560ef557d 100644 --- a/tex/context/base/lxml-aux.lua +++ b/tex/context/base/lxml-aux.lua @@ -20,8 +20,9 @@ local xmlinheritedconvert = xml.inheritedconvert local xmlapplylpath = xml.applylpath local type, setmetatable, getmetatable = type, setmetatable, getmetatable -local insert, remove, fastcopy = table.insert, table.remove, table.fastcopy -local gmatch, gsub = string.gmatch, string.gsub +local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat +local gmatch, gsub, format = string.gmatch, string.gsub, string.format +local utfbyte = utf.byte local function report(what,pattern,c,e) report_xml("%s element '%s' (root: '%s', position: %s, index: %s, pattern: %s)",what,xmlname(e),xmlname(e.__p__),c,e.ni,pattern) @@ -516,6 +517,75 @@ function xml.remapname(root, pattern, newtg, newns, newrn) end --[[ldx-- +<p>Helper (for q2p).</p> +--ldx]]-- + +function xml.cdatatotext(e) + local dt = e.dt + if #dt == 1 then + local first = dt[1] + if first.tg == "@cd@" then + e.dt = first.dt + end + else + -- maybe option + end +end + +xml.builtinentities = table.tohash { "amp", "quot", "apos", "lt", "gt" } -- used often so share + +local entities = characters and characters.entities or nil +local builtinentities = xml.builtinentities + +function xml.addentitiesdoctype(root,option) -- we could also have a 'resolve' i.e. inline hex + if not entities then + require("char-ent") + entities = characters.entities + end + if entities and root and root.tg == "@rt@" and root.statistics then + local list = { } + local hexify = option == "hexadecimal" + for k, v in table.sortedhash(root.statistics.entities.names) do + if not builtinentities[k] then + local e = entities[k] + if not e then + e = format("[%s]",k) + elseif hexify then + e = format("&#%05X;",utfbyte(k)) + end + list[#list+1] = format(" <!ENTITY %s %q >",k,e) + end + end + local dt = root.dt + local n = dt[1].tg == "@pi@" and 2 or 1 + if #list > 0 then + insert(dt, n, { "\n" }) + insert(dt, n, { + tg = "@dt@", -- beware, doctype is unparsed + dt = { format("Something [\n%s\n] ",concat(list)) }, + ns = "", + special = true, + }) + insert(dt, n, { "\n\n" }) + else + -- insert(dt, n, { table.serialize(root.statistics) }) + end + end +end + +-- local str = [==[ +-- <?xml version='1.0' standalone='yes' ?> +-- <root> +-- <a>test test { test</a> +-- <b><![CDATA[oeps]]></b> +-- </root> +-- ]==] +-- +-- local x = xml.convert(str) +-- xml.addentitiesdoctype(x,"hexadecimal") +-- print(x) + +--[[ldx-- <p>Here are a few synonyms.</p> --ldx]]-- @@ -547,3 +617,4 @@ xml.inject_element = xml.inject obsolete.inject_eleme xml.remap_tag = xml.remaptag obsolete.remap_tag = xml.remaptag xml.remap_name = xml.remapname obsolete.remap_name = xml.remapname xml.remap_namespace = xml.remapnamespace obsolete.remap_namespace = xml.remapnamespace + diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index 8710f6d19..5b841e218 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -10,6 +10,10 @@ if not modules then modules = { } end modules ['lxml-tab'] = { -- stripping spaces from e.g. cont-en.xml saves .2 sec runtime so it's not worth the -- trouble +-- todo: when serializing optionally remap named entities to hex (if known in char-ent.lua) +-- maybe when letter -> utf, else name .. then we need an option to the serializer .. a bit +-- of work so we delay this till we cleanup + local trace_entities = false trackers.register("xml.entities", function(v) trace_entities = v end) local report_xml = logs and logs.reporter("xml","core") or function(...) print(format(...)) end @@ -377,7 +381,7 @@ local function unescaped(s) nofprivates = nofprivates + 1 p = utfchar(nofprivates) privates_n[s] = p - s = "&" .. s .. ";" + s = "&" .. s .. ";" -- todo: use char-ent to map to hex privates_u[p] = s privates_p[p] = s end @@ -753,6 +757,13 @@ local function xmlconvert(data, settings) if errorstr and errorstr ~= "" then result.error = true end + result.statistics = { + entities = { + decimals = dcache, + hexadecimals = hcache, + names = acache, + } + } strip, utfize, resolve, resolve_predefined = nil, nil, nil, nil unify_predefined, cleanup, entities = nil, nil, nil stack, top, at, xmlns, errorstr = nil, nil, nil, nil, nil @@ -894,7 +905,7 @@ and then handle the lot.</p> -- new experimental reorganized serialize -local function verbose_element(e,handlers) +local function verbose_element(e,handlers) -- options local handle = handlers.handle local serialize = handlers.serialize local ens, etg, eat, edt, ern = e.ns, e.tg, e.at, e.dt, e.rn @@ -940,7 +951,7 @@ local function verbose_element(e,handlers) for i=1,#edt do local e = edt[i] if type(e) == "string" then - handle(escaped(e)) + handle(escaped(e)) -- option: hexify escaped entities else serialize(e,handlers) end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 99d867160..50327d51d 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 6953be39c..ba65c55fe 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/tabl-tsp.mkiv b/tex/context/base/tabl-tsp.mkiv index 639751dcd..84ea7d540 100644 --- a/tex/context/base/tabl-tsp.mkiv +++ b/tex/context/base/tabl-tsp.mkiv @@ -309,7 +309,6 @@ \tsplitinbetween \unvcopy\tsplittail}% \dowithsplitofffloat{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% - \global\settrue\usesamefloatnumber % new, prevent next increment \doifnotinsidesplitfloat\tsplitafter \endgraf \exitloop @@ -329,10 +328,11 @@ \endgraf \fi \ifinsidecolumns - \doifnotinsidesplitfloat\goodbreak + \goodbreak % was \doifnotinsidesplitfloat\goodbreak \else - \doifnotinsidesplitfloat\page + \page % was \doifnotinsidesplitfloat\page \fi + \global\settrue\usesamefloatnumber % new, prevent next increment \fi}% \global\setfalse\usesamefloatnumber % new, prevent next increment \global\setfalse\splitfloatfirstdone} % we can use this one for tests @@ -374,11 +374,11 @@ \global\settrue\usesamefloatnumber % new, prevent next increment \endgraf \ifconditional\somenextsplitofffloat - \ifinsidecolumns - \goodbreak - \else - \page - \fi + \ifinsidecolumns + \goodbreak + \else + \page + \fi \fi \global\settrue\splitfloatfirstdone \else\ifconditional\somenextsplitofffloat |