retronews

a featureful fork of the luke8086/retronews hn+lobste.rs tui
Log | Files | Refs | README | LICENSE

commit 0ca9709b3679feda2304460f1c9092eb1f32c569
parent 36b1785c1374dbc540a5da4c34939c96f2922c76
Author: luke8086 <55237178+luke8086@users.noreply.github.com>
Date:   Fri, 29 Jul 2022 16:11:45 +0000

Decode HTML entities in message titles

Diffstat:
Mretronews.py | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/retronews.py b/retronews.py @@ -847,7 +847,7 @@ def hn_parse_search_hit(hit: HNSearchHit) -> Message: content_location=f"https://news.ycombinator.com/item?id={hit['objectID']}", date=datetime.fromtimestamp(hit["created_at_i"]), author=hit["author"], - title=hit["title"], + title=html.unescape(hit["title"]), total_comments=(hit["num_comments"] or 0) + 1, ) @@ -855,6 +855,8 @@ def hn_parse_search_hit(hit: HNSearchHit) -> Message: def hn_parse_entry(entry: HNEntry, thread_id: str = "", parent_title: str = "") -> Message: thread_id = thread_id or str(entry["id"]) + my_title = html.unescape(entry["title"]) if entry["title"] else None + body = f"<p>{entry['url']}</p>" if entry["url"] else "" body = f"{body}{entry['text']}" if entry["text"] else body @@ -864,9 +866,9 @@ def hn_parse_entry(entry: HNEntry, thread_id: str = "", parent_title: str = "") content_location=f"https://news.ycombinator.com/item?id={entry['id']}", date=datetime.fromtimestamp(entry["created_at_i"]), author=entry["author"] or "unknown", - title=entry["title"] or f"Re: {parent_title}", + title=my_title or f"Re: {parent_title}", body=body, - children=[hn_parse_entry(child, thread_id, entry["title"] or parent_title) for child in entry["children"]], + children=[hn_parse_entry(child, thread_id, my_title or parent_title) for child in entry["children"]], )