allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [7/7] allura git commit: [#6923] Use emoji library and update regex
Date Tue, 23 Oct 2018 20:11:10 GMT
[#6923] Use emoji library and update regex


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/9bb9f99f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9bb9f99f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9bb9f99f

Branch: refs/heads/master
Commit: 9bb9f99febacd24883d056073d653980c8bc859d
Parents: 1d51f52
Author: Shalitha Suranga <shalithasuranga@gmail.com>
Authored: Mon Oct 22 12:38:29 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Oct 23 19:56:51 2018 +0000

----------------------------------------------------------------------
 Allura/allura/lib/markdown_extensions.py | 16 +++++++---------
 requirements.txt                         |  3 +++
 2 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/9bb9f99f/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 161b31c..ef5258b 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 #       Licensed to the Apache Software Foundation (ASF) under one
 #       or more contributor license agreements.  See the NOTICE file
 #       distributed with this work for additional information
@@ -25,6 +27,7 @@ import html5lib
 import html5lib.serializer
 import html5lib.filters.alphabeticalattributes
 import markdown
+import emoji
 
 from . import macro
 from . import helpers as h
@@ -275,29 +278,24 @@ class ForgeExtension(markdown.Extension):
 
 class EmojiExtension(markdown.Extension):
 
-    EMOJI_RE = r'(:[+\-\w]+:)'
-    EMOJI_LIST = {
-        ':+1:' : u'\U0001F44D',
-        ':smile:' : u'\U0001F642'
-    }
+    EMOJI_RE = u'(%s[a-zA-Z0-9\+\-_&.ô’Åéãíç()!#*]+%s)' % (':', ':')
 
     def __init__(self, **kwargs):
         markdown.Extension.__init__(self)
         
     def extendMarkdown(self, md, md_globals):
-        pattern = EmojiInlinePattern(self.EMOJI_RE, self.EMOJI_LIST)
+        pattern = EmojiInlinePattern(self.EMOJI_RE)
         md.inlinePatterns.add('emoji', pattern,'<not_strong')
 
         
 class EmojiInlinePattern(markdown.inlinepatterns.Pattern):
     
-    def __init__(self, pattern, emojis):
+    def __init__(self, pattern):
         markdown.inlinepatterns.Pattern.__init__(self, pattern)
-        self.emojis = emojis
         
     def handleMatch(self, m):
         emoji_code = m.group(2)
-        return self.emojis.get(emoji_code)
+        return emoji.emojize(emoji_code, use_aliases=True)
 
 
 class ForgeLinkPattern(markdown.inlinepatterns.LinkPattern):

http://git-wip-us.apache.org/repos/asf/allura/blob/9bb9f99f/requirements.txt
----------------------------------------------------------------------
diff --git a/requirements.txt b/requirements.txt
index cd80c24..16662cb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -103,3 +103,6 @@ gunicorn==19.4.5
 
 # markdown extensions
 markdown-checklist==0.4.1
+
+# emoji library
+emoji==0.5.1


Mime
View raw message