From 9c1dd2f9f7b4107bb5613c967bfd18fe3a5ae0ba Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sat, 16 Jul 2016 22:30:51 +0200 Subject: [PATCH] =?UTF-8?q?-=20Neue=20Funktion=20zum=20simplen=20Escapen?= =?UTF-8?q?=20von=20Markdown=20(ohne=20das=20"tanzende=20M=C3=A4nnchen")?= =?UTF-8?q?=20-=20RSS:=20=C3=9Cberfl=C3=BCssige=20\n=20werden=20rausgeschn?= =?UTF-8?q?itten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otouto/plugins/rss.lua | 2 +- otouto/plugins/youtube.lua | 4 +--- otouto/utilities.lua | 7 +++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/otouto/plugins/rss.lua b/otouto/plugins/rss.lua index 442ba49..256e5dd 100644 --- a/otouto/plugins/rss.lua +++ b/otouto/plugins/rss.lua @@ -344,7 +344,7 @@ function rss:cron(self_plz) else content = '' end - text = text..'\n#RSS: *'..title..'*\n'..utilities.md_escape(content)..' [Weiterlesen]('..link..')\n' + text = text..'\n#RSS: *'..title..'*\n'..utilities.trim(utilities.markdown_escape_simple(content))..' [Weiterlesen]('..link..')\n' end if text ~= '' then local newlast = newentr[1].id diff --git a/otouto/plugins/youtube.lua b/otouto/plugins/youtube.lua index 5b1f6f0..2d490b4 100644 --- a/otouto/plugins/youtube.lua +++ b/otouto/plugins/youtube.lua @@ -98,9 +98,7 @@ function get_yt_thumbnail(data) end function send_youtube_data(data, msg, self, link, sendpic) - local title = data.snippet.localized.title - local title = title:gsub('%*', '\\*') - local title = title:gsub('`', '\\`') + local title = utilities.markdown_escape_simple(data.snippet.localized.title) -- local description = data.snippet.localized.description local uploader = data.snippet.channelTitle local upload_date = makeOurDate(data.snippet.publishedAt) diff --git a/otouto/utilities.lua b/otouto/utilities.lua index f089071..763359b 100644 --- a/otouto/utilities.lua +++ b/otouto/utilities.lua @@ -497,6 +497,13 @@ function utilities.markdown_escape(text) return text end +function utilities.markdown_escape_simple(text) + text = text:gsub('_', '\\_') + text = text:gsub('%*', '\\*') + text = text:gsub('`', '\\`') + return text +end + utilities.md_escape = utilities.markdown_escape utilities.triggers_meta = {}