summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lxml-tab.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-02-15 11:15:07 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-02-15 11:15:07 +0100
commita036ac2dd19b592316e1b479360e9e6c6700e935 (patch)
tree321156a4e2af995a7f401e1b773fd8813e3928da /tex/context/base/mkiv/lxml-tab.lua
parentd73f5987ca04dbdf0a134236c3314dadd7a73565 (diff)
downloadcontext-a036ac2dd19b592316e1b479360e9e6c6700e935.tar.gz
2016-02-15 10:29:00
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