summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lxml-tex.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-01-18 23:15:08 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-01-18 23:15:08 +0100
commit975f4f9f2d71d8021900955404f8b144ca6895f5 (patch)
treece7dcd5288845a485bc8d457e6c705a87a020b10 /tex/context/base/mkiv/lxml-tex.lua
parente200230205ec1297f8d3ade3d491585f85d87fff (diff)
downloadcontext-975f4f9f2d71d8021900955404f8b144ca6895f5.tar.gz
2016-01-18 22:24:00
Diffstat (limited to 'tex/context/base/mkiv/lxml-tex.lua')
-rw-r--r--tex/context/base/mkiv/lxml-tex.lua28
1 files changed, 20 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/lxml-tex.lua b/tex/context/base/mkiv/lxml-tex.lua
index 718b8f8c6..aad86ed6d 100644
--- a/tex/context/base/mkiv/lxml-tex.lua
+++ b/tex/context/base/mkiv/lxml-tex.lua
@@ -233,9 +233,13 @@ local _, ctxtextcapture_nop = context.newtexthandler {
catcodes = ctxcatcodes,
}
-local xmltextcapture, xmlspacecapture, xmllinecapture, ctxtextcapture
+local xmltextcapture = xmltextcapture_yes
+local xmlspacecapture = xmlspacecapture_yes
+local xmllinecapture = xmllinecapture_yes
+local ctxtextcapture = ctxtextcapture_yes
+local prefertexentities = true
-function lxml.setescapedentities(v)
+directives.register("lxml.entities.escaped",function(v)
if v then
xmltextcapture = xmltextcapture_yes
xmlspacecapture = xmlspacecapture_yes
@@ -247,11 +251,11 @@ function lxml.setescapedentities(v)
xmllinecapture = xmllinecapture_nop
ctxtextcapture = ctxtextcapture_nop
end
-end
-
-lxml.setescapedentities() -- off by default (for now)
+end)
-directives.register("lxml.escapedentities",lxml.setescapedentities)
+directives.register("lxml.entities.prefertex",function(v)
+ prefertex = v
+end)
-- cdata
@@ -464,8 +468,16 @@ function xml.load(filename,settings)
return xmltable
end
-local function entityconverter(id,str,ent) -- todo ent optional
- return xmlentities[str] or ent[str] or xmlprivatetoken(str) or "" -- roundtrip handler
+-- local function entityconverter(id,str,ent) -- todo ent optional
+-- return xmlentities[str] or ent[str] or xmlprivatetoken(str) or "" -- roundtrip handler
+-- end
+
+local function entityconverter(id,str,ent) -- todo: disable tex entities when raw
+ if prefertexentities then
+ return xmlentities[str] or (texentities[str] and xmlprivatetoken(str)) or ent[str] or xmlprivatetoken(str) or "" -- roundtrip handler
+ else
+ return xmlentities[str] or ent[str] or (texentities[str] and xmlprivatetoken(str)) or xmlprivatetoken(str) or "" -- roundtrip handler
+ end
end
local function lxmlconvert(id,data,compress,currentresource)