summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/context/lua/mtxrun.lua11
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua11
-rw-r--r--scripts/context/stubs/unix/mtxrun11
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/lxml-ent.lua37
-rw-r--r--tex/context/base/lxml-ini.mkiv4
-rw-r--r--tex/context/base/lxml-tab.lua11
-rw-r--r--tex/context/base/lxml-tex.lua61
-rw-r--r--tex/context/base/status-files.pdfbin23483 -> 23470 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin155009 -> 155084 bytes
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
14 files changed, 107 insertions, 49 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index abd4f964c..d0cf3d46d 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -6693,7 +6693,9 @@ local function handle_any_entity(str)
if resolve then
local a = acache[str] -- per instance ! todo
if not a then
+print(">1",str,a)
a = resolve_predefined and predefined_simplified[str]
+print(">2",str,a)
if a then
-- one of the predefined
elseif type(resolve) == "function" then
@@ -6701,15 +6703,20 @@ local function handle_any_entity(str)
else
a = entities[str]
end
+print(">3",str,a)
if a then
if type(a) == "function" then
- report_xml("expanding entity &%s; (function)",str)
+ if trace_entities then
+ report_xml("expanding entity &%s; (function)",str)
+ end
a = a(str) or ""
end
+print(">4",str,a)
+ a = lpegmatch(parsedentity,a) or a
+print(">5",str,a)
if trace_entities then
report_xml("resolved entity &%s; -> %s (internal)",str,a)
end
- a = lpegmatch(parsedentity,a) or a
else
local unknown_any_entity = placeholders.unknown_any_entity
if unknown_any_entity then
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index abd4f964c..d0cf3d46d 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -6693,7 +6693,9 @@ local function handle_any_entity(str)
if resolve then
local a = acache[str] -- per instance ! todo
if not a then
+print(">1",str,a)
a = resolve_predefined and predefined_simplified[str]
+print(">2",str,a)
if a then
-- one of the predefined
elseif type(resolve) == "function" then
@@ -6701,15 +6703,20 @@ local function handle_any_entity(str)
else
a = entities[str]
end
+print(">3",str,a)
if a then
if type(a) == "function" then
- report_xml("expanding entity &%s; (function)",str)
+ if trace_entities then
+ report_xml("expanding entity &%s; (function)",str)
+ end
a = a(str) or ""
end
+print(">4",str,a)
+ a = lpegmatch(parsedentity,a) or a
+print(">5",str,a)
if trace_entities then
report_xml("resolved entity &%s; -> %s (internal)",str,a)
end
- a = lpegmatch(parsedentity,a) or a
else
local unknown_any_entity = placeholders.unknown_any_entity
if unknown_any_entity then
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index abd4f964c..d0cf3d46d 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -6693,7 +6693,9 @@ local function handle_any_entity(str)
if resolve then
local a = acache[str] -- per instance ! todo
if not a then
+print(">1",str,a)
a = resolve_predefined and predefined_simplified[str]
+print(">2",str,a)
if a then
-- one of the predefined
elseif type(resolve) == "function" then
@@ -6701,15 +6703,20 @@ local function handle_any_entity(str)
else
a = entities[str]
end
+print(">3",str,a)
if a then
if type(a) == "function" then
- report_xml("expanding entity &%s; (function)",str)
+ if trace_entities then
+ report_xml("expanding entity &%s; (function)",str)
+ end
a = a(str) or ""
end
+print(">4",str,a)
+ a = lpegmatch(parsedentity,a) or a
+print(">5",str,a)
if trace_entities then
report_xml("resolved entity &%s; -> %s (internal)",str,a)
end
- a = lpegmatch(parsedentity,a) or a
else
local unknown_any_entity = placeholders.unknown_any_entity
if unknown_any_entity then
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 42ccd18b0..266deee0f 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.06.09 00:59}
+\newcontextversion{2011.06.09 12:49}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index dc05044d3..d1064187d 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{2011.06.09 00:59}
+\newcontextversion{2011.06.09 12:49}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index a9ee8b97d..842e4294d 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.06.09 00:59}
+\edef\contextversion{2011.06.09 12:49}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 97c7bad50..5a328d52a 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.06.09 00:59}
+\edef\contextversion{2011.06.09 12:49}
%D For those who want to use this:
diff --git a/tex/context/base/lxml-ent.lua b/tex/context/base/lxml-ent.lua
index f525d42d2..d47b44c2f 100644
--- a/tex/context/base/lxml-ent.lua
+++ b/tex/context/base/lxml-ent.lua
@@ -28,15 +28,11 @@ local report_xml = logs.reporter("xml")
local xml = xml
-xml.entities = xml.entities or { } -- xml.entity_handler == function
+xml.entities = xml.entities or { }
-storage.register("xml/entities",xml.entities,"xml.entities") -- this will move to lxml
+storage.register("xml/entities", xml.entities, "xml.entities" )
-local entities = xml.entities -- this is a shared hash
-
-xml.placeholders.unknown_any_entity = nil -- has to be per xml
-
-local parsedentity = xml.parsedentitylpeg
+local entities = xml.entities -- maybe some day properties
function xml.registerentity(key,value)
entities[key] = value
@@ -45,29 +41,6 @@ function xml.registerentity(key,value)
end
end
-function xml.resolvedentity(str)
- local e = entities[str]
- if e then
- local te = type(e)
- if te == "function" then
- e(str)
- elseif e then
- texsprint(ctxcatcodes,e)
- end
- else
- -- resolve hex and dec, todo: escape # & etc for ctxcatcodes
- -- normally this is already solved while loading the file
- local chr, err = lpegmatch(parsedentity,str)
- if chr then
- texsprint(ctxcatcodes,chr)
- elseif err then
- texsprint(ctxcatcodes,err)
- else
- texsprint(ctxcatcodes,"\\xmle{",str,"}{",utfupper(str),"}") -- we need to use our own upper
- end
- end
-end
-
--~ entities.amp = function() tex.write("&") end
--~ entities.lt = function() tex.write("<") end
--~ entities.gt = function() tex.write(">") end
@@ -87,3 +60,7 @@ if characters and characters.entities then
end
end
+
+local trace_entities = false trackers.register("xml.entities", function(v) trace_entities = v end)
+
+local report_xml = logs.reporter("xml")
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index f54bfa0be..d044aaf75 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -340,10 +340,8 @@
\setnewconstant\xmlautoentities\plusone % 0=off, 1=upper, 2=upper,lower
-\let\isolatedentity\firstofoneargument
-
\def\xmlsetentity#1#2{\ctxlua{xml.registerentity('#1',\!!bs\detokenize{#2}\!!es)}}
-\def\xmltexentity#1#2{\ctxlua{xml.registerentity('#1',\!!bs\detokenize{\isolatedentity{#2}}\!!es)}}
+\def\xmltexentity#1#2{\ctxlua{lxml.registerentity('#1',\!!bs\detokenize{#2}\!!es)}}
% \xmlsetentity{tex}{\TEX{}} % {} needed
diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua
index 1c52e4013..1df41eb33 100644
--- a/tex/context/base/lxml-tab.lua
+++ b/tex/context/base/lxml-tab.lua
@@ -390,7 +390,9 @@ local function handle_any_entity(str)
if resolve then
local a = acache[str] -- per instance ! todo
if not a then
+print(">1",str,a)
a = resolve_predefined and predefined_simplified[str]
+print(">2",str,a)
if a then
-- one of the predefined
elseif type(resolve) == "function" then
@@ -398,15 +400,20 @@ local function handle_any_entity(str)
else
a = entities[str]
end
+print(">3",str,a)
if a then
if type(a) == "function" then
- report_xml("expanding entity &%s; (function)",str)
+ if trace_entities then
+ report_xml("expanding entity &%s; (function)",str)
+ end
a = a(str) or ""
end
+print(">4",str,a)
+ a = lpegmatch(parsedentity,a) or a
+print(">5",str,a)
if trace_entities then
report_xml("resolved entity &%s; -> %s (internal)",str,a)
end
- a = lpegmatch(parsedentity,a) or a
else
local unknown_any_entity = placeholders.unknown_any_entity
if unknown_any_entity then
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index 441cdb264..eff2c6297 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -42,6 +42,61 @@ local trace_comments = false trackers.register("lxml.comments", function(v) tra
local report_lxml = logs.reporter("xml","tex")
+-- tex entities
+
+lxml.entities = lxml.entities or { }
+
+storage.register("lxml/entities",lxml.entities,"lxml.entities")
+
+--~ xml.placeholders.unknown_any_entity = nil -- has to be per xml
+
+local xmlentities = xml.entities
+local texentities = lxml.entities
+local parsedentity = xml.parsedentitylpeg
+
+function lxml.registerentity(key,value)
+ texentities[key] = value
+ if trace_entities then
+ report_xml("registering tex entity '%s' as: %s",key,value)
+ end
+end
+
+function lxml.resolvedentity(str)
+ local e = texentities[str]
+ if e then
+ local te = type(e)
+ if te == "function" then
+ e(str)
+ elseif e then
+ context(e)
+ end
+ return
+ end
+ local e = xmlentities[str]
+ if e then
+ local te = type(e)
+ if te == "function" then
+ e = e(str)
+ end
+ if e then
+ texsprint(notcatcodes,e)
+ end
+ return
+ end
+ -- resolve hex and dec, todo: escape # & etc for ctxcatcodes
+ -- normally this is already solved while loading the file
+ local chr, err = lpegmatch(parsedentity,str)
+ if chr then
+ context(chr)
+ elseif err then
+ context(err)
+ else
+ context.xmle(str,utfupper(str)) -- we need to use our own upper
+ end
+end
+
+-- tex interface
+
lxml.loaded = lxml.loaded or { }
local loaded = lxml.loaded
@@ -72,14 +127,14 @@ local xmltextcapture = (
space^0 * newline^2 * Cc("") / texprint + -- better ^-2 ?
space^0 * newline * space^0 * Cc(" ") / texsprint +
content / function(str) return texsprint(notcatcodes,str) end + -- was just texsprint, current catcodes regime is notcatcodes
- entity / xml.resolvedentity
+ entity / lxml.resolvedentity
)^0
local ctxtextcapture = (
space^0 * newline^2 * Cc("") / texprint + -- better ^-2 ?
space^0 * newline * space^0 * Cc(" ") / texsprint +
content / function(str) return texsprint(ctxcatcodes,str) end + -- was just texsprint, current catcodes regime is notcatcodes
- entity / xml.resolvedentity
+ entity / lxml.resolvedentity
)^0
local forceraw, rawroot = false, nil
@@ -349,7 +404,7 @@ function lxml.convert(id,data,entities,compress)
end
if entities and entities == variables.yes then
settings.utfize_entities = true
- settings.resolve_entities = function (str) return entityconverter(id,str) end
+ -- settings.resolve_entities = function (str) return entityconverter(id,str) end
end
return xml.convert(data,settings)
end
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 40b67769f..6ed453c24 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 c1308ced5..692de4b23 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 098fe4c0d..c90043534 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 06/09/11 00:59:00
+-- merge date : 06/09/11 12:49:16
do -- begin closure to overcome local limits and interference