From 666d25e294d41d7ec7450ff34e5cc3eb1463d3da 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, 19 Aug 2021 21:13:37 +0800 Subject: improve markdown --- script/provider/markdown.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'script/provider/markdown.lua') diff --git a/script/provider/markdown.lua b/script/provider/markdown.lua index 7b94157e..140267d7 100644 --- a/script/provider/markdown.lua +++ b/script/provider/markdown.lua @@ -58,9 +58,7 @@ function mt:string() elseif obj.type == 'markdown' then concat(obj.markdown) else - if obj.language == language then - lines[#lines+1] = obj.text - else + if obj.language ~= language then if language ~= 'md' then lines[#lines+1] = '```' end @@ -70,9 +68,18 @@ function mt:string() if obj.language ~= 'md' then lines[#lines+1] = '```' .. obj.language end - lines[#lines+1] = obj.text - language = obj.language end + if obj.language == 'md' and #lines > 0 then + local last = lines[#lines] + if obj.text:sub(1, 1) == '@' + or last:sub(1, 1) == '@' then + if lines[#lines] ~= '' then + lines[#lines+1] = '' + end + end + end + lines[#lines+1] = obj.text + language = obj.language end end end -- cgit v1.2.3