From 85c9d4565fce30f8afdd8b0663b50de89900f36f Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:30:21 -0700 Subject: Collect an email filter's writes like the others --- custom/extensions/email-gravatar.lua | 11 ++++++----- custom/extensions/email-libravatar.lua | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'custom/extensions') diff --git a/custom/extensions/email-gravatar.lua b/custom/extensions/email-gravatar.lua index aebb27c..467deff 100644 --- a/custom/extensions/email-gravatar.lua +++ b/custom/extensions/email-gravatar.lua @@ -47,7 +47,7 @@ local base_url = "https://gravatar.com/avatar/" -- One name reaches this filter as an open, writes and a close, so what the -- open works out is kept here for the close. -local buffer = "" +local chunks = {} local avatar_hash = nil local function hash_hex(input) @@ -96,7 +96,7 @@ local function normalize_email(email) end function filter_open(email, page) - buffer = "" + chunks = {} local address = normalize_email(email) if address == nil or not has_digest then avatar_hash = nil @@ -106,7 +106,7 @@ function filter_open(email, page) end function filter_write(text) - buffer = buffer .. text + chunks[#chunks + 1] = text end local function avatar_url(size) @@ -118,14 +118,15 @@ end -- off the critical path. The icon only decorates the name beside it, so its -- alt text is empty and a screen reader goes straight to the name. function filter_close() + local text = table.concat(chunks) if avatar_hash == nil then - html(buffer) + html(text) else html(" " .. buffer) + "' loading='lazy' decoding='async'> " .. text) end return 0 end diff --git a/custom/extensions/email-libravatar.lua b/custom/extensions/email-libravatar.lua index fca67a7..0a6e10c 100644 --- a/custom/extensions/email-libravatar.lua +++ b/custom/extensions/email-libravatar.lua @@ -46,7 +46,7 @@ local base_url = "https://seccdn.libravatar.org/avatar/" -- One name reaches this filter as an open, writes and a close, so what the -- open works out is kept here for the close. -local buffer = "" +local chunks = {} local avatar_hash = nil local function hash_hex(input) @@ -95,7 +95,7 @@ local function normalize_email(email) end function filter_open(email, page) - buffer = "" + chunks = {} local address = normalize_email(email) if address == nil or not has_digest then avatar_hash = nil @@ -105,7 +105,7 @@ function filter_open(email, page) end function filter_write(text) - buffer = buffer .. text + chunks[#chunks + 1] = text end local function avatar_url(size) @@ -117,14 +117,15 @@ end -- off the critical path. The icon only decorates the name beside it, so its -- alt text is empty and a screen reader goes straight to the name. function filter_close() + local text = table.concat(chunks) if avatar_hash == nil then - html(buffer) + html(text) else html(" " .. buffer) + "' loading='lazy' decoding='async'> " .. text) end return 0 end -- cgit