From a036ac2dd19b592316e1b479360e9e6c6700e935 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Mon, 15 Feb 2016 11:15:07 +0100 Subject: 2016-02-15 10:29:00 --- tex/context/base/mkiv/lxml-tab.lua | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'tex/context/base/mkiv/lxml-tab.lua') 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 -- cgit v1.2.3