summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lxml-xml.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/lxml-xml.lua')
-rw-r--r--tex/context/base/mkiv/lxml-xml.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/lxml-xml.lua b/tex/context/base/mkiv/lxml-xml.lua
index d1520800f..47a6e8c85 100644
--- a/tex/context/base/mkiv/lxml-xml.lua
+++ b/tex/context/base/mkiv/lxml-xml.lua
@@ -19,6 +19,10 @@ local xmlserialize = xml.serialize
local xmlcollected = xml.collected
local xmlnewhandlers = xml.newhandlers
+local reparsedentity = xml.reparsedentitylpeg -- \Ux{...}
+local unescapedentity = xml.unescapedentitylpeg
+local parsedentity = reparsedentity
+
local function first(collected) -- wrong ?
return collected and collected[1]
end
@@ -355,6 +359,25 @@ function xml.text(id,pattern) -- brrr either content or element (when cdata)
end
end
+function xml.pure(id,pattern)
+ if pattern then
+ local collected = xmlfilter(id,pattern)
+ if collected and #collected > 0 then
+ parsedentity = unescapedentity
+ local s = collected and #collected > 0 and xmltotext(collected[1]) or ""
+ parsedentity = reparsedentity
+ return s
+ else
+ return ""
+ end
+ else
+ parsedentity = unescapedentity
+ local s = xmltotext(id) or ""
+ parsedentity = reparsedentity
+ return s
+ end
+end
+
xml.content = text
--