summaryrefslogtreecommitdiffhomepage
path: root/libs/core/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-08-20 16:40:25 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-08-20 16:40:25 +0000
commit5b718fe88d64c8b33ab0ef2c3d5d2ac26d8c154d (patch)
treef034cf26d75cb8ed0faafee6a60cff153056fae3 /libs/core/luasrc
parentd141bf49120cb2898e1c3df2d845d25e6215a604 (diff)
* luci/libs: add striptags() to luci.util
Diffstat (limited to 'libs/core/luasrc')
-rw-r--r--libs/core/luasrc/util.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index c6d9ec6ce1..66e368299f 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -208,6 +208,13 @@ function pcdata(value)
return value:gsub(">", "&gt;")
end
+--- Strip HTML tags from given string.
+-- @param value String containing the HTML text
+-- @return String with HTML tags stripped of
+function striptags(s)
+ return (s:gsub("</?[A-Za-z][A-Za-z0-9:_%-]*[^>]*>", " "):gsub("%s+", " "))
+end
+
--- Splits given string on a defined separator sequence and return a table
-- containing the resulting substrings. The optional max parameter specifies
-- the number of bytes to process, regardless of the actual length of the given