diff options
author | Marius <mariausol@gmail.com> | 2012-05-22 02:40:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-05-22 02:40:13 +0300 |
commit | ffb360b52944514197aa47313c26816cd2fb7a7e (patch) | |
tree | af46811e825bb977838cd2db44646879f281b752 /tex/context/base/lxml-aux.lua | |
parent | 3821b4213bf250551cfa122313ae2c56f9923533 (diff) | |
download | context-ffb360b52944514197aa47313c26816cd2fb7a7e.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.lua | 30 |
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 |