From 0dee6235ccb494724dd53914cf78a0500a91a2ac Mon Sep 17 00:00:00 2001
From: Waseem Daher
Date: Tue, 5 Mar 2013 15:53:35 -0500
Subject: [PATCH] Don't image-ify :( and other smileys :disappointed:
(imported from commit 25323f19572c24da36267064a1ca820d80c9db79)
---
zephyr/lib/bugdown/__init__.py | 41 ----------------------------------
zephyr/tests.py | 19 +++-------------
2 files changed, 3 insertions(+), 57 deletions(-)
diff --git a/zephyr/lib/bugdown/__init__.py b/zephyr/lib/bugdown/__init__.py
index 20e872b307..ca8c0ca4d7 100644
--- a/zephyr/lib/bugdown/__init__.py
+++ b/zephyr/lib/bugdown/__init__.py
@@ -86,39 +86,6 @@ class Gravatar(markdown.inlinepatterns.Pattern):
% (gravatar_hash(match.group('email')),))
return img
-# We first map syntax of the form ":)" to the ":smile:" syntax, and
-# then map syntax of the form ":foo:" to the emoji named "foo".
-smiley_to_emoji = {
- # We're somewhat restrained here, to avoid false positives
- ":-)" : "blush", # This is a very weird coopting of the blush emoticon, but the normal
- ":)" : "blush", # smile was so smiley that it became indistinguishable from grin.
- ":-(" : "worried",
- ":(" : "worried",
- ";-)" : "wink",
- ";)" : "wink",
- ":-P" : "stuck_out_tongue",
- ":-p" : "stuck_out_tongue",
- ":P" : "stuck_out_tongue",
- ":p" : "stuck_out_tongue",
- ":-*" : "kissing_closed_eyes",
- ":*" : "kissing_closed_eyes",
- "8-)" : "sunglasses",
- "8)" : "sunglasses",
- "O:-)": "innocent",
- "O:)" : "innocent",
- "o:-)": "innocent",
- "o:)" : "innocent",
- ":-/" : "confused",
- ":/" : "confused",
- ":'(" : "cry",
- ":-D" : "smiley",
- ":D" : "smiley",
- ":-|" : "expressionless",
- ":|" : "expressionless",
- "<3" : "heart",
- }
-smiley_regex = '|'.join([re.escape(face) for face in smiley_to_emoji])
-
path_to_emoji = os.path.join(os.path.dirname(__file__), '..', '..',
# This should be zephyr/
'static', 'third', 'gemoji', 'images', 'emoji', '*.png')
@@ -140,13 +107,6 @@ class Emoji(markdown.inlinepatterns.Pattern):
return orig_syntax
return make_emoji(name, orig_syntax)
-class Smiley(markdown.inlinepatterns.Pattern):
- def handleMatch(self, match):
- orig_syntax = match.group("syntax")
- if orig_syntax not in smiley_to_emoji:
- return orig_syntax
- return make_emoji(smiley_to_emoji[orig_syntax], orig_syntax)
-
def fixup_link(link):
"""Set certain attributes we want on every link."""
link.set('target', '_blank')
@@ -303,7 +263,6 @@ class Bugdown(markdown.Extension):
md.inlinePatterns.add('gravatar', Gravatar(r'!gravatar\((?P[^)]*)\)'), '_begin')
md.inlinePatterns.add('emoji', Emoji(r'(?:[^:\s]+:)(?!\S)'), '_begin')
- md.inlinePatterns.add('smileys', Smiley(r'(?' + smiley_regex + r')(?!\S)'), '_begin')
md.inlinePatterns.add('link', LinkPattern(markdown.inlinepatterns.LINK_RE, md), '>backtick')
# markdown.inlinepatterns.Pattern compiles this with re.UNICODE, which
diff --git a/zephyr/tests.py b/zephyr/tests.py
index c0981ff08f..d713278143 100644
--- a/zephyr/tests.py
+++ b/zephyr/tests.py
@@ -11,7 +11,7 @@ from zephyr.tornadoviews import json_get_updates, api_get_messages
from zephyr.decorator import RespondAsynchronously, RequestVariableConversionError
from zephyr.lib.initial_password import initial_password, initial_api_key
from zephyr.lib.actions import do_send_message, gather_subscriptions
-from zephyr.lib.bugdown import convert, emoji_list, smiley_to_emoji
+from zephyr.lib.bugdown import convert, emoji_list
import simplejson
import subprocess
@@ -1954,26 +1954,13 @@ xxxxxxx
\nxxxxxxx xxxxx xxxx xxxxx:
\nxxxxxx: xxx
(':whale:', emoji_img(':whale:')),
(':fakeemoji:', ':fakeemoji:'),
(':even faker smile:', ':even faker smile:'),
- # Smileys
- (':)', emoji_img(':)', 'blush')),
- (';)', emoji_img(';)', 'wink')),
- ('8)', emoji_img('8)', 'sunglasses')),
- ('o:)', emoji_img('o:)', 'innocent')),
- ('<3', emoji_img('<3', 'heart')),
- (':(', emoji_img(':(', 'worried')),
- ('x<3', 'x<3')]
+ ]
# Check every single emoji
for img in emoji_list:
emoji_text = ":%s:" % img
test_cases.append((emoji_text, emoji_img(emoji_text)))
- # Check every single smiley
- for smiley, emoji in smiley_to_emoji.iteritems():
- # Fixup for <3
- smiley_escaped_text = smiley.replace('<', '<')
- test_cases.append((smiley, emoji_img(smiley_escaped_text, emoji)))
-
for input, expected in test_cases:
self.assertEqual(convert(input), '
%s
' % expected)
@@ -1981,7 +1968,7 @@ xxxxxxx\nxxxxxxx xxxxx xxxx xxxxx:
\nxxxxxx: xxx
msg = 'test :smile: again :poop:\n:) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:'
converted = convert(msg)
self.assertEqual(converted, '
test ' + emoji_img(':smile:') + ' again ' + emoji_img(':poop:') + '
\n'
- + emoji_img(':)', 'blush') + ' foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:
')
+ + ':) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:')
def test_multiline_strong(self):