summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lxml-tab.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/lxml-tab.lua')
-rw-r--r--tex/context/base/mkiv/lxml-tab.lua43
1 files changed, 42 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua
index 23f424995..b03c7eb43 100644
--- a/tex/context/base/mkiv/lxml-tab.lua
+++ b/tex/context/base/mkiv/lxml-tab.lua
@@ -793,7 +793,48 @@ do
+ p_rest/fromdec
)
- xml.reparsedentitylpeg = reparsedentity
+ local hash = table.setmetatableindex(function(t,k)
+ local v = utfchar(k)
+ t[k] = v
+ return v
+ end)
+
+ local function fromuni(s)
+ local n = tonumber(s,16)
+ if n then
+ return hash[n]
+ else
+ return formatters["u:%s"](s), true
+ end
+ end
+
+ local function fromhex(s)
+ local n = tonumber(s,16)
+ if n then
+ return hash[n]
+ else
+ return formatters["h:%s"](s), true
+ end
+ end
+
+ local function fromdec(s)
+ local n = tonumber(s)
+ if n then
+ return hash[n]
+ else
+ return formatters["d:%s"](s), true
+ end
+ end
+
+ local unescapedentity =
+ P("U+") * (p_rest/fromuni)
+ + P("#") * (
+ P("x") * (p_rest/fromhex)
+ + p_rest/fromdec
+ )
+
+ xml.reparsedentitylpeg = reparsedentity -- with \Ux{...} for special tex entities
+ xml.unescapedentitylpeg = unescapedentity -- normal characters
end