summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lxml-ent.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lxml-ent.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lxml-ent.lua45
1 files changed, 15 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/context/base/lxml-ent.lua b/Master/texmf-dist/tex/context/base/lxml-ent.lua
index 5b24d9d6846..be69dec00ee 100644
--- a/Master/texmf-dist/tex/context/base/lxml-ent.lua
+++ b/Master/texmf-dist/tex/context/base/lxml-ent.lua
@@ -7,7 +7,6 @@ if not modules then modules = { } end modules ['lxml-ent'] = {
}
local type, next, tonumber = type, next, tonumber
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local utf = unicode.utf8
local byte, format = string.byte, string.format
local utfupper, utfchar = utf.upper, utf.char
@@ -28,15 +27,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 +40,19 @@ 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)
+if characters and characters.entities then
+
+ function characters.registerentities(forcecopy)
+ if forcecopy then
+ table.setmetatableindex(entities,nil)
+ for name, value in next, characters.entities do
+ if not entities[name] then
+ entities[name] = value
+ end
+ end
else
- texsprint(ctxcatcodes,"\\xmle{",str,"}{",utfupper(str),"}") -- we need to use our own upper
+ table.setmetatableindex(entities,characters.entities)
end
end
-end
-entities.amp = function() tex.write("&") end
-entities.lt = function() tex.write("<") end
-entities.gt = function() tex.write(">") end
+end