From c0ec365561851b07d23e81156d993cca04dc130a Mon Sep 17 00:00:00 2001 From: Eloi Torrents Date: Fri, 5 Sep 2025 16:22:50 +0200 Subject: [PATCH] Refactor to move logic into enrich_msg --- src/rss.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/rss.py b/src/rss.py index dfec833..22543c4 100644 --- a/src/rss.py +++ b/src/rss.py @@ -38,9 +38,16 @@ def _is_image_token(token: str, extensions): return len(parts) == 2 and parts[1] in extensions # this is similar to the markup function in microblog -def enrich_msg(lines, is_atom=True, accepted_images=[], base_url=None): +def enrich_msg( + lines, + is_atom=True, + accepted_images=[], + base_url=None, + trailing_punctuation=None, + desc_len_limit=-1, +): if not is_atom: - return lines + return line2words(lines, desc_len_limit, trailing_punctuation) content = [] parser = My_Html_Parser([]) for line in lines: @@ -99,17 +106,16 @@ def write_feed(posts, filename, params, tagname=None): msg = post.message ti = " ".join( line2words(msg, TITLE_LEN_LIMIT, params["trailing_punctuation"])) - if params["use_atom"]: - de = " ".join( - enrich_msg( - msg, - base_url=params["url"], - accepted_images=params["accepted_images"], - ) + de = " ".join( + enrich_msg( + msg, + is_atom=params["use_atom"], + base_url=params["url"], + accepted_images=params["accepted_images"], + trailing_punctuation=params["trailing_punctuation"], + desc_len_limit=DESC_LEN_LIMIT, ) - else: - de = " ".join( - line2words(msg, DESC_LEN_LIMIT, params["trailing_punctuation"])) + ) li = base_url + ("#%i" % post.num) p = dateutil.parser.parse(post.timestamp) if params["use_atom"]: