Comparison

mod_pubsub_summary/mod_pubsub_summary.lua @ 5135:35085e0d52ad

mod_pubsub_summary: Trim preceding and trailing whitespace from title To improve formatting of titles encoded like <title> Lorem Ipsum </title>
author Kim Alvefur <zash@zash.se>
date Tue, 10 Jan 2023 16:05:01 +0100
parent 5131:82e7251d4f52
comparison
equal deleted inserted replaced
5134:e0d0ef564095 5135:35085e0d52ad
2 -- 2 --
3 -- Compose a textual representation of Atom payloads 3 -- Compose a textual representation of Atom payloads
4 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event) 4 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event)
5 local payload = event.payload; 5 local payload = event.payload;
6 local title = payload:get_child_text("title"); 6 local title = payload:get_child_text("title");
7 if title then title = title:gsub("^%s+", ""):gsub("%s+$", ""); end
7 -- Note: This prefers content over summary, it was made for a news feed where 8 -- Note: This prefers content over summary, it was made for a news feed where
8 -- the interesting stuff was in the content and the summary was .. meh. 9 -- the interesting stuff was in the content and the summary was .. meh.
9 local content_tag = payload:get_child("content") or payload:get_child("summary"); 10 local content_tag = payload:get_child("content") or payload:get_child("summary");
10 local content = content_tag and content_tag:get_text(); 11 local content = content_tag and content_tag:get_text();
11 if content and content_tag.attr.type == "html" then 12 if content and content_tag.attr.type == "html" then