mod_pubsub_summary: Trim preceding and trailing whitespace from title
authorKim Alvefur <zash@zash.se>
Tue, 10 Jan 2023 16:05:01 +0100
changeset 5139 35085e0d52ad
parent 5138 e0d0ef564095
child 5140 67b2c982bea2
mod_pubsub_summary: Trim preceding and trailing whitespace from title To improve formatting of titles encoded like <title> Lorem Ipsum </title>
mod_pubsub_summary/mod_pubsub_summary.lua
--- a/mod_pubsub_summary/mod_pubsub_summary.lua	Sun Jan 08 17:54:11 2023 +0100
+++ b/mod_pubsub_summary/mod_pubsub_summary.lua	Tue Jan 10 16:05:01 2023 +0100
@@ -4,6 +4,7 @@
 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event)
 	local payload = event.payload;
 	local title = payload:get_child_text("title");
+	if title then title = title:gsub("^%s+", ""):gsub("%s+$", ""); end
 	-- Note: This prefers content over summary, it was made for a news feed where
 	-- the interesting stuff was in the content and the summary was .. meh.
 	local content_tag = payload:get_child("content") or payload:get_child("summary");