From b8da814892aca07b495be571bfd0a150e6eb4c66 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Sep 2019 11:32:04 +0100 Subject: [PATCH] Handle emoji with trailing chatacters --- content.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/content.py b/content.py index 4db8c3482..fa7868380 100644 --- a/content.py +++ b/content.py @@ -250,12 +250,15 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ continue if addHashTags(wordStr,httpPrefix,originalDomain,replaceHashTags,hashtags): continue - if len(wordStr)>2 and wordStr.startswith(':') and wordStr.endswith(':') and not emojiDict: - print('Loading emoji lookup') - if not os.path.isfile(baseDir+'/emoji/emoji.json'): - copyfile(baseDir+'/emoji/default_emoji.json',baseDir+'/emoji/emoji.json') - with open(baseDir+'/emoji/emoji.json', 'r') as fp: - emojiDict=commentjson.load(fp) + if len(wordStr)>2: + if wordStr.startswith(':') and ':' in wordStr[1:] and not emojiDict: + if not wordStr.endswith(':'): + wordStr=':'+wordStr[1:].split(':')[0]+':' + print('Loading emoji lookup') + if not os.path.isfile(baseDir+'/emoji/emoji.json'): + copyfile(baseDir+'/emoji/default_emoji.json',baseDir+'/emoji/emoji.json') + with open(baseDir+'/emoji/emoji.json', 'r') as fp: + emojiDict=commentjson.load(fp) addEmoji(baseDir,wordStr,httpPrefix,originalDomain,replaceEmoji,hashtags,emojiDict)