Loosen up emoji regex. (i.e. More emojis! 👍)

Now parsed: 🍺,🍺;🍺!

 If \w characters surround :foo:, we still say it's NOT an
 emoji, but we used to do this for \S characters, so it's loosened up.

(imported from commit 49b33d2f0ffdcfde8947ae411a4addcf4c24af9c)
This commit is contained in:
Steve Howell 2013-08-06 16:23:55 -04:00
parent 237953f656
commit 9f9c7c3e3b
2 changed files with 11 additions and 1 deletions

View File

@ -580,7 +580,7 @@ class Bugdown(markdown.Extension):
md.inlinePatterns.add('gravatar', Gravatar(r'!gravatar\((?P<email>[^)]*)\)'), '_begin') md.inlinePatterns.add('gravatar', Gravatar(r'!gravatar\((?P<email>[^)]*)\)'), '_begin')
md.inlinePatterns.add('usermention', UserMentionPattern(mention.find_mentions), '>backtick') md.inlinePatterns.add('usermention', UserMentionPattern(mention.find_mentions), '>backtick')
md.inlinePatterns.add('emoji', Emoji(r'(?<!\S)(?P<syntax>:[^:\s]+:)(?!\S)'), '_begin') md.inlinePatterns.add('emoji', Emoji(r'(?<!\w)(?P<syntax>:[^:\s]+:)(?!\w)'), '_begin')
md.inlinePatterns.add('link', AtomicLinkPattern(markdown.inlinepatterns.LINK_RE, md), '>backtick') md.inlinePatterns.add('link', AtomicLinkPattern(markdown.inlinepatterns.LINK_RE, md), '>backtick')
for (pattern, format_string) in self.getConfig("realm_filters"): for (pattern, format_string) in self.getConfig("realm_filters"):

View File

@ -2510,6 +2510,16 @@ xxxxxxx</strong></p>\n<p>xxxxxxx xxxxx xxxx xxxxx:<br>\n<code>xxxxxx</code>: xxx
self.assertEqual(converted, '<p>test ' + emoji_img(':smile:') + ' again ' + emoji_img(':poop:') + '<br>\n' self.assertEqual(converted, '<p>test ' + emoji_img(':smile:') + ' again ' + emoji_img(':poop:') + '<br>\n'
+ ':) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:</p>') + ':) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:</p>')
msg = ':smile:, :smile:; :smile:'
converted = bugdown_convert(msg)
self.assertEqual(converted,
'<p>' +
emoji_img(':smile:') +
', ' +
emoji_img(':smile:') +
'; ' +
emoji_img(':smile:') +
'</p>')
def test_multiline_strong(self): def test_multiline_strong(self):
msg = "Welcome to **the jungle**" msg = "Welcome to **the jungle**"