Software /
code /
prosody-modules
Diff
mod_pubsub_summary/mod_pubsub_summary.lua @ 4513:ade2064160e3
mod_pubsub_summary: Fix to not strip inline links
Links were turned into `label <url>` and then a later pass removed the
`<url>` part leaving only the label. This should avoid that. Escaping is
hard.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 17 Mar 2021 15:52:12 +0100 |
parent | 4507:86a97e7572b2 |
child | 4600:98864dffb231 |
line wrap: on
line diff
--- a/mod_pubsub_summary/mod_pubsub_summary.lua Sun Mar 14 23:31:32 2021 +0100 +++ b/mod_pubsub_summary/mod_pubsub_summary.lua Wed Mar 17 15:52:12 2021 +0100 @@ -11,7 +11,7 @@ if content and content_tag.attr.type == "html" then content = content:gsub("\n*<p[^>]*>\n*(.-)\n*</p>\n*", "%1\n\n"); content = content:gsub("<li>(.-)</li>\n", "* %1\n"); - content = content:gsub("<a[^>]*href=[\"'](.-)[\"'][^>]*>(.-)</a>", "%2 <%1>"); + content = content:gsub("<a[^>]*href=[\"'](.-)[\"'][^>]*>(.-)</a>", "\1%1\2%2\3"); content = content:gsub("<b>(.-)</b>", "*%1*"); content = content:gsub("<strong>(.-)</strong>", "*%1*"); content = content:gsub("<em>(.-)</em>", "*%1*"); @@ -19,6 +19,7 @@ content = content:gsub("<img[^>]*src=[\"'](.-)[\"'][^>]*>", " %1 "); -- TODO alt= would have been nice to grab content = content:gsub("<br[^>]*>", "\n"); content = content:gsub("<[^>]+>", ""); + content = content:gsub("\1(.-)\2(.-)\3", "%2 <%1>"); content = content:gsub("^%s*", ""):gsub("%s*$", ""); content = content:gsub("\n\n\n+", "\n\n"); content = content:gsub("&(%w+);", {