From cb1a412bc7c205c73aec3ef2b1f8f8baf4564fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 20 Aug 2021 17:52:06 +0800 Subject: stash --- script/provider/markdown.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'script/provider/markdown.lua') diff --git a/script/provider/markdown.lua b/script/provider/markdown.lua index 140267d7..3a215f0f 100644 --- a/script/provider/markdown.lua +++ b/script/provider/markdown.lua @@ -15,6 +15,7 @@ function mt:add(language, text) if not text then return end + self._cacheResult = nil if type(text) == 'table' then self[#self+1] = { type = 'markdown', @@ -34,12 +35,16 @@ function mt:add(language, text) end function mt:splitLine() + self._cacheResult = nil self[#self+1] = { type = 'splitline', } end function mt:string() + if self._cacheResult then + return self._cacheResult + end local lines = {} local language = 'md' @@ -97,7 +102,9 @@ function mt:string() end end - return table.concat(lines, '\n') + local result = table.concat(lines, '\n') + self._cacheResult = result + return result end return function () -- cgit v1.2.3