From 7c245ae7a2bc5e2d8c328ce10bedbe8110c698bf Mon Sep 17 00:00:00 2001 From: "Vadim A. Misbakh-Soloviov" Date: Wed, 19 Apr 2017 10:33:30 +0700 Subject: [PATCH] "settext" node method implementation. Fixes #38 --- src/htmlparser/ElementNode.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/htmlparser/ElementNode.lua b/src/htmlparser/ElementNode.lua index 106eb5c..381fb90 100644 --- a/src/htmlparser/ElementNode.lua +++ b/src/htmlparser/ElementNode.lua @@ -117,14 +117,18 @@ function ElementNode:gettext() return string.sub(self.root._text, self._openstart, self._closeend) end -function ElementNode:getcontent() - return string.sub(self.root._text, self._openend + 1, self._closestart - 1) +function ElementNode:settext(c) + self.root._text=c end function ElementNode:textonly() return (self:gettext():gsub("<[^>]*>","")) end +function ElementNode:getcontent() + return string.sub(self.root._text, self._openend + 1, self._closestart - 1) +end + function ElementNode:addattribute(k, v) self.attributes[k] = v if string.lower(k) == "id" then