From 75e80c59932d4d743989c5a0806953d8636ef589 Mon Sep 17 00:00:00 2001 From: Eloi Torrents Date: Fri, 5 Sep 2025 12:24:41 +0200 Subject: [PATCH] expose trailing_punctuation to rss --- example/settings.toml | 2 +- src/rss.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/example/settings.toml b/example/settings.toml index a6108e9..79c5f46 100644 --- a/example/settings.toml +++ b/example/settings.toml @@ -12,7 +12,6 @@ landing_page="index.html" [post] accepted_images= ["jpg", "JPG", "png", "PNG"] -trailing_punctuation = ".,)!?>];:" # true = add

tags to each line. tag_paragraphs=true # apply

tags even if a line contains the following @@ -86,3 +85,4 @@ title="Your Microblog Title Here" title_tagged = "#{__tagname__} on {__title__}" url = "https://yourdomain.tld/microblog/" description = "Your description here." +trailing_punctuation = ".,)!?>];:" diff --git a/src/rss.py b/src/rss.py index 9ec9807..bf40eb4 100644 --- a/src/rss.py +++ b/src/rss.py @@ -11,7 +11,7 @@ except ImportError: print("\trss disabled - missing dependency", file=sys.stderr) print("\tYour microblog still may have been generated.", file=sys.stderr) -def line2words(lines, limit): +def line2words(lines, limit, trailing_punctuation): output = [] char_count = 0 break_outer_loop = False @@ -29,8 +29,7 @@ def line2words(lines, limit): # last char of last word last_char = output[-1].strip()[-1] # print(output[-1], file=sys.stderr) - punctuation = [".", ")", ",", "!", "?", ">", ']'] - if last_char not in punctuation: + if last_char not in trailing_punctuation: output.append("...") return output @@ -99,7 +98,7 @@ def write_feed(posts, filename, params, tagname=None): # len of post.message is number of lines msg = post.message ti = " ".join( - line2words(msg,TITLE_LEN_LIMIT)) + line2words(msg, TITLE_LEN_LIMIT, params["trailing_punctuation"])) if params["use_atom"]: de = " ".join( enrich_msg( @@ -110,7 +109,7 @@ def write_feed(posts, filename, params, tagname=None): ) else: de = " ".join( - line2words(msg,DESC_LEN_LIMIT)) + line2words(msg, DESC_LEN_LIMIT, params["trailing_punctuation"])) li = base_url + ("#%i" % post.num) p = dateutil.parser.parse(post.timestamp) if params["use_atom"]: