diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/lxml-ent.lua | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lxml-ent.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lxml-ent.lua | 45 |
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 |