From 5bd083238f7bc0aef1a993aec1af41b4ed85f7c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Feb 2026 07:15:28 +0000 Subject: [PATCH 1/2] Fix HTML entities appearing in copied output for story titles story_title from the Algolia API can contain HTML entities (', &, etc.) which were passed through to the output without decoding. comment_text was already decoded via htmlToText but story_title was not. https://claude.ai/code/session_01M9HD38yY9BBnzPzdKuGDR3 --- hn-comments-for-user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hn-comments-for-user.html b/hn-comments-for-user.html index 88f6957..7802de8 100644 --- a/hn-comments-for-user.html +++ b/hn-comments-for-user.html @@ -65,7 +65,7 @@

Hacker News comments for a user

const date = formatDate(h.created_at); const commentUrl = `https://news.ycombinator.com/item?id=${h.objectID}`; const threadUrl = h.story_id ? `https://news.ycombinator.com/item?id=${h.story_id}` : ''; - const storyTitle = h.story_title || h.title || '(no title)'; + const storyTitle = htmlToText(h.story_title || h.title || '') || '(no title)'; const text = htmlToText(h.comment_text); return [ `Date: ${date}`, From 094ae471756225f8097f1b14a79029719058f3d6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Feb 2026 07:34:13 +0000 Subject: [PATCH 2/2] Decode percent-encoded sequences in comment text output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit URLs in HN comment text (from Algolia API) contain percent-encoded characters like %C4%81 (ā) and %3C (<). The htmlToText function decoded HTML entities but left percent-encoding intact, so copied output contained raw sequences like K%C4%81k%C4%81p%C5%8D instead of Kākāpō. Add a post-processing step that decodes consecutive %XX sequences via decodeURIComponent, with a try/catch fallback for malformed sequences. https://claude.ai/code/session_01M9HD38yY9BBnzPzdKuGDR3 --- hn-comments-for-user.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hn-comments-for-user.html b/hn-comments-for-user.html index 7802de8..18d7afc 100644 --- a/hn-comments-for-user.html +++ b/hn-comments-for-user.html @@ -48,7 +48,10 @@

Hacker News comments for a user

if (!html) return ''; const div = document.createElement('div'); div.innerHTML = html; - return (div.textContent || div.innerText || '').trim(); + const text = (div.textContent || div.innerText || '').trim(); + return text.replace(/(%[0-9A-Fa-f]{2})+/g, m => { + try { return decodeURIComponent(m); } catch(e) { return m; } + }); }; async function fetchComments(user) {