summaryrefslogtreecommitdiff
path: root/tex/context/base/lxml-aux.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-05-22 01:22:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-05-22 01:22:00 +0200
commit3ecd4ddc188bb441690ea80cef39a06a875c9701 (patch)
tree4baa10dc663d18380857843629be0ab7b49d11c0 /tex/context/base/lxml-aux.lua
parent2895f6edd9f6692d7941a84e30ca06254338dfa8 (diff)
downloadcontext-3ecd4ddc188bb441690ea80cef39a06a875c9701.tar.gz
beta 2012.05.22 01:22
Diffstat (limited to 'tex/context/base/lxml-aux.lua')
-rw-r--r--tex/context/base/lxml-aux.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua
index 7df6179a0..09411bfc0 100644
--- a/tex/context/base/lxml-aux.lua
+++ b/tex/context/base/lxml-aux.lua
@@ -559,6 +559,36 @@ function xml.cdatatotext(e)
end
end
+-- local x = xml.convert("<x><a>1<b>2</b>3</a></x>")
+-- xml.texttocdata(xml.first(x,"a"))
+-- print(x) -- <x><![CDATA[1<b>2</b>3]]></x>
+
+function xml.texttocdata(e) -- could be a finalizer
+ local dt = e.dt
+ local s = xml.tostring(dt) -- no shortcut?
+ e.tg = "@cd@"
+ e.special = true
+ e.ns = ""
+ e.rn = ""
+ e.dt = { s }
+ e.at = nil
+end
+
+-- local x = xml.convert("<x><a>1<b>2</b>3</a></x>")
+-- xml.tocdata(xml.first(x,"a"))
+-- print(x) -- <x><![CDATA[<a>1<b>2</b>3</a>]]></x>
+
+function xml.elementtocdata(e) -- could be a finalizer
+ local dt = e.dt
+ local s = xml.tostring(e) -- no shortcut?
+ e.tg = "@cd@"
+ e.special = true
+ e.ns = ""
+ e.rn = ""
+ e.dt = { s }
+ e.at = nil
+end
+
xml.builtinentities = table.tohash { "amp", "quot", "apos", "lt", "gt" } -- used often so share
local entities = characters and characters.entities or nil