blob: ca76ec89adb60f655fc08960ae1b2c8bf1c96c65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
|