From 07a1b0fde89e8b45a005f6a59676d1d28a5788bb Mon Sep 17 00:00:00 2001 From: "Vadim A. Misbakh-Soloviov" Date: Wed, 19 Apr 2017 10:29:26 +0700 Subject: [PATCH] "textonly" node method implementation. Fixes #47 --- src/htmlparser/ElementNode.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/htmlparser/ElementNode.lua b/src/htmlparser/ElementNode.lua index 4b7b3ef..106eb5c 100644 --- a/src/htmlparser/ElementNode.lua +++ b/src/htmlparser/ElementNode.lua @@ -121,6 +121,10 @@ function ElementNode:getcontent() return string.sub(self.root._text, self._openend + 1, self._closestart - 1) end +function ElementNode:textonly() + return (self:gettext():gsub("<[^>]*>","")) +end + function ElementNode:addattribute(k, v) self.attributes[k] = v if string.lower(k) == "id" then