Replace emoji tags

main2
Bob Mottram 2019-09-23 12:34:24 +01:00
parent a8689b749c
commit 218693f7b1
2 changed files with 10 additions and 4 deletions

View File

@ -111,7 +111,7 @@ def loadEmojiDict(emojiDataFilename: str,emojiDict: {}) -> None:
emojiName=emojiName.split('..')[0] emojiName=emojiName.split('..')[0]
emojiDict[emojiName.lower()]=emojiUnicode emojiDict[emojiName.lower()]=emojiUnicode
def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji: {},postTags: {},emojiDict: {}) -> bool: def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji: {},postTags: {},emojiDict: {},inMessageContent: bool) -> bool:
"""Detects Emoji and adds them to the replacements dict """Detects Emoji and adds them to the replacements dict
Also updates the tags list to be added to the post Also updates the tags list to be added to the post
""" """
@ -144,6 +144,8 @@ def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji:
'name': ':'+emoji+':', 'name': ':'+emoji+':',
'type': 'Emoji' 'type': 'Emoji'
} }
if not inMessageContent:
# when altering emoji in display name
replaceEmoji[wordStr]='<img src="'+emojiUrl+'" title="'+emoji+'" alt="'+emoji+'"/>' replaceEmoji[wordStr]='<img src="'+emojiUrl+'" title="'+emoji+'" alt="'+emoji+'"/>'
return True return True

View File

@ -1745,10 +1745,12 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \
if displayName: if displayName:
if ':' in displayName: if ':' in displayName:
displayName=displayName.replace('<p>','').replace('</p>','') displayName=displayName.replace('<p>','').replace('</p>','')
emojiTags={}
displayName= \ displayName= \
addHtmlTags(baseDir,httpPrefix, \ addHtmlTags(baseDir,httpPrefix, \
nickname,domain,displayName,[],{}) nickname,domain,displayName,[],emojiTags)
displayName=displayName.replace('<p>','').replace('</p>','') displayName=displayName.replace('<p>','').replace('</p>','')
displayName=htmlRemplaceEmojiFromTags(displayName,emojiTags)
titleStr+='<a href="'+messageId+'">'+displayName+'</a>' titleStr+='<a href="'+messageId+'">'+displayName+'</a>'
else: else:
titleStr+='<a href="'+messageId+'">@'+actorNickname+'@'+actorDomain+'</a>' titleStr+='<a href="'+messageId+'">@'+actorNickname+'@'+actorDomain+'</a>'
@ -1873,10 +1875,12 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \
if displayName: if displayName:
if ':' in displayName: if ':' in displayName:
displayName=displayName.replace('<p>','').replace('</p>','') displayName=displayName.replace('<p>','').replace('</p>','')
emojiTags={}
displayName= \ displayName= \
addHtmlTags(baseDir,httpPrefix, \ addHtmlTags(baseDir,httpPrefix, \
nickname,domain,displayName,[],{}) nickname,domain,displayName,[],emojiTags)
displayName=displayName.replace('<p>','').replace('</p>','') displayName=displayName.replace('<p>','').replace('</p>','')
displayName=htmlRemplaceEmojiFromTags(displayName,emojiTags)
titleStr=displayName+' '+titleStr titleStr=displayName+' '+titleStr
avatarImageInPost= \ avatarImageInPost= \