diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-22 22:14:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-22 22:14:39 +0000 |
commit | fc4466b32ed330a956ac603b00fd145524cff49a (patch) | |
tree | 2c50e2b8de13aa9233b2c76dffe201558f169e86 /Master/texmf-dist/tex/context/base/mkiv/lxml-ent.lua | |
parent | 50e2368597d5f6fe2057195d0ae6a9f2044923e4 (diff) |
context (22apr16)
git-svn-id: svn://tug.org/texlive/trunk@40691 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/lxml-ent.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/lxml-ent.lua | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lxml-ent.lua b/Master/texmf-dist/tex/context/base/mkiv/lxml-ent.lua new file mode 100644 index 00000000000..c392713f0a3 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkiv/lxml-ent.lua @@ -0,0 +1,66 @@ +if not modules then modules = { } end modules ['lxml-ent'] = { + version = 1.001, + comment = "this module is the basis for the lxml-* ones", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local type, next, tonumber = type, next, tonumber +local byte, format = string.byte, string.format +local utfchar = utf.char +local lpegmatch = lpeg.match +local setmetatableindex = table.setmetatableindex + +--[[ldx-- +<p>We provide (at least here) two entity handlers. The more extensive +resolver consults a hash first, tries to convert to <l n='utf'/> next, +and finaly calls a handler when defines. When this all fails, the +original entity is returned.</p> + +<p>We do things different now but it's still somewhat experimental</p> +--ldx]]-- + +local trace_entities = false trackers.register("xml.entities", function(v) trace_entities = v end) + +local report_xml = logs.reporter("xml") + +local xml = xml + +xml.entities = xml.entities or { } + +storage.register("xml/entities", xml.entities, "xml.entities" ) + +local entities = xml.entities -- maybe some day properties + +function xml.registerentity(key,value) + entities[key] = value + if trace_entities then + report_xml("registering entity %a as %a",key,value) + end +end + +if characters and characters.entities then + + -- the big entity table also has amp, quot, apos, lt, gt in them + + local loaded = false + + function characters.registerentities(forcecopy) + if loaded then + return + end + if forcecopy then + setmetatableindex(entities,nil) + for name, value in next, characters.entities do + if not entities[name] then + entities[name] = value + end + end + else + setmetatableindex(entities,characters.entities) + end + loaded = true + end + +end |