diff --git a/content.py b/content.py index ca5ba0e0..5b6b4c2f 100644 --- a/content.py +++ b/content.py @@ -254,7 +254,7 @@ def removeLongWords(content: str,maxWordLength: int,longWordsList: []) -> str: def addHtmlTags(baseDir: str,httpPrefix: str, \ nickname: str,domain: str,content: str, \ - recipients: [],hashtags: {}) -> str: + recipients: [],hashtags: {},isJsonContent=False) -> str: """ Replaces plaintext mentions such as @nick@domain into html by matching against known following accounts """ @@ -340,9 +340,10 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ content=content.replace(wordStr,replaceStr) for wordStr,replaceStr in replaceHashTags.items(): content=content.replace(wordStr,replaceStr) - for wordStr,replaceStr in replaceEmoji.items(): - content=content.replace(wordStr,replaceStr) - + if not isJsonContent: + for wordStr,replaceStr in replaceEmoji.items(): + content=content.replace(wordStr,replaceStr) + content=addWebLinks(content) if longWordsList: content=removeLongWords(content,maxWordLength,longWordsList) diff --git a/posts.py b/posts.py index 8e04003f..2c5809ab 100644 --- a/posts.py +++ b/posts.py @@ -483,7 +483,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ addHtmlTags(baseDir,httpPrefix, \ nickname,domain,content, \ mentionedRecipients, \ - hashtagsDict) + hashtagsDict,True) statusNumber,published = getStatusNumber() postTo='https://www.w3.org/ns/activitystreams#Public' diff --git a/tests.py b/tests.py index db8d3de6..8ba7ac4e 100644 --- a/tests.py +++ b/tests.py @@ -1559,13 +1559,15 @@ def testAddEmoji(): contentModified= \ addHtmlTags(baseDir,httpPrefix, \ nickname,domain,content, \ - recipients,hashtags) + recipients,hashtags,True) + assert ':lemon:' in contentModified tags=[] for tagName,tag in hashtags.items(): tags.append(tag) content=contentModified contentModified=replaceEmojiFromTags(content,tags,'content') assert 'img src' in contentModified + assert ':lemon:' not in contentModified os.chdir(baseDirOriginal) shutil.rmtree(baseDirOriginal+'/.tests')