scrap the is_atom logic in enrich_msg
This commit is contained in:
parent
77499c700d
commit
a372df0951
17
src/rss.py
17
src/rss.py
@ -42,7 +42,6 @@ def _is_image_token(token: str, extensions):
|
||||
# this is similar to the markup function in microblog
|
||||
def enrich_msg(
|
||||
lines,
|
||||
is_atom=True,
|
||||
accepted_images=[],
|
||||
base_url="",
|
||||
trailing_punctuation="",
|
||||
@ -57,6 +56,7 @@ def enrich_msg(
|
||||
words = line.split()
|
||||
for i in range(len(words)):
|
||||
word = words[i]
|
||||
core = word.rstrip(trailing_punctuation)
|
||||
if word.find("src=") == 0 \
|
||||
or word.find("href=") == 0:
|
||||
continue
|
||||
@ -64,14 +64,12 @@ def enrich_msg(
|
||||
w = escape(word)
|
||||
new_word = ("<a href=\"%s\">%s</a>") % (w, w)
|
||||
words[i] = new_word
|
||||
elif not is_atom:
|
||||
core = word.rstrip(trailing_punctuation)
|
||||
if _is_image_token(core, accepted_images):
|
||||
suffix = word[len(core):]
|
||||
abs_url = urljoin(base_url, core)
|
||||
anchor = f"<a href=\"{escape(abs_url)}\">{escape(abs_url)}</a>"
|
||||
new_word = anchor + suffix
|
||||
words[i] = new_word
|
||||
elif _is_image_token(core, accepted_images):
|
||||
suffix = word[len(core):]
|
||||
abs_url = urljoin(base_url, core)
|
||||
anchor = f"<a href=\"{escape(abs_url)}\">{escape(abs_url)}</a>"
|
||||
new_word = anchor + suffix
|
||||
words[i] = new_word
|
||||
words.insert(0,"<p>")
|
||||
words.append("</p>")
|
||||
content.append(" ".join(words))
|
||||
@ -117,7 +115,6 @@ def write_feed(posts, filename, params, tagname=None):
|
||||
de = " ".join(
|
||||
enrich_msg(
|
||||
msg,
|
||||
is_atom=params["use_atom"],
|
||||
base_url=params["url"],
|
||||
accepted_images=params["accepted_images"],
|
||||
trailing_punctuation=params["trailing_punctuation"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user