From c481991fee74022dd261fab3bd5f07f472b9f9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 9 Jun 2022 00:44:28 +0800 Subject: update config --- script/provider/markdown.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'script/provider/markdown.lua') diff --git a/script/provider/markdown.lua b/script/provider/markdown.lua index 6b7d24c8..de24e314 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 self end + assert(type(text) == 'string') self._cacheResult = nil if type(text) == 'table' then self[#self+1] = { @@ -40,7 +41,15 @@ function mt:splitLine() return self end -function mt:string() +function mt:emptyLine() + self._cacheResult = nil + self[#self+1] = { + type = 'emptyline', + } + return self +end + +function mt:string(nl) if self._cacheResult then return self._cacheResult end @@ -59,6 +68,11 @@ function mt:string() lines[#lines+1] = '' lines[#lines+1] = '---' end + elseif obj.type == 'emptyline' then + if #lines > 0 + and lines[#lines] ~= '' then + lines[#lines+1] = '' + end elseif obj.type == 'markdown' then concat(obj.markdown) else @@ -101,7 +115,7 @@ function mt:string() end end - local result = table.concat(lines, '\n') + local result = table.concat(lines, nl or '\n') self._cacheResult = result return result end -- cgit v1.2.3