diff --git a/content.py b/content.py index 8b140c1f..b7c110e4 100644 --- a/content.py +++ b/content.py @@ -31,6 +31,20 @@ def removeHtmlTag(htmlStr: str, tag: str) -> str: return htmlStr +def setHtmlTag(htmlStr: str, tag: str, value: str) -> str: + """Removes a given tag from a html string + """ + matchStr = ' ' + tag + '="' + if matchStr not in htmlStr: + return htmlStr + sections = htmlStr.split(matchStr, 1) + if '"' not in sections[1]: + return htmlStr + htmlStr = sections[0] + matchStr + value + '"' + \ + sections[1].split('"', 1)[1] + return htmlStr + + def removeQuotesWithinQuotes(content: str) -> str: """Removes any blockquote inside blockquote """ diff --git a/newsdaemon.py b/newsdaemon.py index df393ab0..9e4ae8ba 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -12,6 +12,7 @@ import datetime from collections import OrderedDict from newswire import getDictFromNewswire from posts import createNewsPost +from content import setHtmlTag from content import removeHtmlTag from content import dangerousMarkup from utils import loadJson @@ -134,7 +135,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, # remove image dimensions if '