diff options
author | Marius <mariausol@gmail.com> | 2010-08-20 10:35:18 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-08-20 10:35:18 +0300 |
commit | 20da4ce347921be291c8804041bd8756e3bf1707 (patch) | |
tree | e079545741aeb84163b5888e77449c780e0233d6 /tex/context/base/lxml-mis.lua | |
parent | 7d7e0d3c8d778650105cfb479f31a2bb54d69d50 (diff) | |
download | context-20da4ce347921be291c8804041bd8756e3bf1707.tar.gz |
beta 2010.08.20 00:00
Diffstat (limited to 'tex/context/base/lxml-mis.lua')
-rw-r--r-- | tex/context/base/lxml-mis.lua | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tex/context/base/lxml-mis.lua b/tex/context/base/lxml-mis.lua index 78297b592..94a26b974 100644 --- a/tex/context/base/lxml-mis.lua +++ b/tex/context/base/lxml-mis.lua @@ -6,12 +6,16 @@ if not modules then modules = { } end modules ['lxml-mis'] = { license = "see context related readme files" } +local xml, lpeg, string = xml, lpeg, string + local concat = table.concat local type, next, tonumber, tostring, setmetatable, loadstring = type, next, tonumber, tostring, setmetatable, loadstring local format, gsub, match = string.format, string.gsub, string.match -local lpegmatch = lpeg.match +local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns +local P, S, R, C, V, Cc, Cs = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.V, lpeg.Cc, lpeg.Cs -local xml = xml +lpegpatterns.xml = lpegpatterns.xml or { } +local xmlpatterns = lpegpatterns.xml --[[ldx-- <p>The following helper functions best belong to the <t>lxml-ini</t> @@ -37,7 +41,7 @@ end --~ xml.gsub = xmlgsub -function xml.strip_leading_spaces(dk,d,k) -- cosmetic, for manual +function xml.stripleadingspaces(dk,d,k) -- cosmetic, for manual if d and k then local dkm = d[k-1] if dkm and type(dkm) == "string" then @@ -54,8 +58,6 @@ end --~ function xml.unescaped(str) return (gsub(str,"(&.-;)", xml.unescapes)) end --~ function xml.cleansed (str) return (gsub(str,"<.->" , '' )) end -- "%b<>" -local P, S, R, C, V, Cc, Cs = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.V, lpeg.Cc, lpeg.Cs - -- 100 * 2500 * "oeps< oeps> oeps&" : gsub:lpeg|lpeg|lpeg -- -- 1021:0335:0287:0247 @@ -80,9 +82,9 @@ local unescaped = Cs(normal * (special * normal)^0) local cleansed = Cs(((P("<") * (1-P(">"))^0 * P(">"))/"" + 1)^0) -xml.escaped_pattern = escaped -xml.unescaped_pattern = unescaped -xml.cleansed_pattern = cleansed +xmlpatterns.escaped = escaped +xmlpatterns.unescaped = unescaped +xmlpatterns.cleansed = cleansed function xml.escaped (str) return lpegmatch(escaped,str) end function xml.unescaped(str) return lpegmatch(unescaped,str) end |