diff --git a/newsdaemon.py b/newsdaemon.py index 2d69be9f8..eb5b358e3 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -610,6 +610,9 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, # save the post and update the index if savePost: + # ensure that all hashtags are stored in the json + # and appended to the content + blog['object']['tag'] = [] for tagName in hashtags: htId = tagName.replace('#', '') hashtagUrl = \ @@ -620,13 +623,24 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, 'type': 'Hashtag' } blog['object']['tag'].append(newTag) + hashtagHtml = \ + "#" + \ + htId + "" if tagName in blog['object']['content']: - hashtagHtml = \ - "#" + \ - htId + "" blog['object']['content'].replace(tagName, hashtagHtml) + else: + content = blog['object']['content'] + if hashtagHtml not in content: + if content.endswith('

'): + content = \ + content[:len(content) - len('

')] + \ + hashtagHtml + '

' + else: + content += hashtagHtml + blog['object']['content'] = content + storeHashTags(baseDir, 'news', blog) newswire[originalDateStr][6] = hashtags