From 4ca61ec457822dd14966afa0752340ae8ce180a1 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 Nov 2020 21:57:09 +0800 Subject: no longer beta --- script/provider/markdown.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 script/provider/markdown.lua (limited to 'script/provider/markdown.lua') diff --git a/script/provider/markdown.lua b/script/provider/markdown.lua new file mode 100644 index 00000000..ca76ec89 --- /dev/null +++ b/script/provider/markdown.lua @@ -0,0 +1,26 @@ +local mt = {} +mt.__index = mt +mt.__name = 'markdown' + +function mt:add(language, text) + if not text or #text == 0 then + return + end + if language == 'md' then + if self._last == 'md' then + self[#self+1] = '' + end + self[#self+1] = text + else + self[#self+1] = ('```%s\n%s\n```'):format(language, text) + end + self._last = language +end + +function mt:string() + return table.concat(self, '\n') +end + +return function () + return setmetatable({}, mt) +end -- cgit v1.2.3