def test_shortcode_to_image(self):
     txt = 'Hello world! 😄 :smile:'
     expected = """Hello world! 😄 <img class="emojione" alt="😄" src="https://cdn.jsdelivr.net/emojione/assets/3.0/png/64/1f604.png"/>"""
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = False
     expected = """Hello world! 😄 <img class="emojione" alt=":smile:" src="https://cdn.jsdelivr.net/emojione/assets/3.0/png/64/1f604.png"/>"""
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = True
Beispiel #2
0
 def test_shortcode_to_image(self):
     txt = 'Hello world! 😄 :smile:'
     expected = """Hello world! 😄 <img class="emojione" alt="😄" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f604.png"/>"""
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = False
     expected = """Hello world! 😄 <img class="emojione" alt=":smile:" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f604.png"/>"""
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = True
Beispiel #3
0
 def test_shortcode_to_image(self):
     txt = 'Hello world! 😄 :smile:'
     expected = """Hello world! 😄 <img class="emojione" alt="😄" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png%s"/>""" %\
                Emoji.cache_bust_param
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = False
     expected = """Hello world! 😄 <img class="emojione" alt=":smile:" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png%s"/>""" %\
                Emoji.cache_bust_param
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = True
Beispiel #4
0
 def test_shortcode_to_image(self):
     txt = 'Hello world! 😄 :smile:'
     expected = """Hello world! 😄 <img class="emojione" alt="😄" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png%s"/>""" %\
                Emoji.cache_bust_param
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = False
     expected = """Hello world! 😄 <img class="emojione" alt=":smile:" src="//cdn.jsdelivr.net/emojione/assets/png/1F604.png%s"/>""" %\
                Emoji.cache_bust_param
     self.assertEqual(Emoji.shortcode_to_image(txt), expected)
     Emoji.unicode_alt = True
Beispiel #5
0
 def test_emoji_at_end_of_sentence_with_preceeding_colon(self):
     unicode = "Emoji One's official mascot: 🐌"
     shortcode = "Emoji One's official mascot: :snail:"
     image = (
         'Emoji One\'s official mascot: <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/>'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #6
0
 def test_emoji_inside_sentence_with_comma(self):
     unicode = "The 🐌, is Emoji One's official mascot."
     shortcode = "The :snail:, is Emoji One's official mascot."
     image = (
         'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + "\"/>, is Emoji One's official mascot."
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #7
0
 def test_emoji_at_start_of_sentence_with_apostrophe(self):
     unicode = "🐌's are cool!"
     shortcode = ":snail:'s are cool!"
     image = (
         '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + "\"/>'s are cool!"
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #8
0
 def test_emoji_at_start_of_sentence(self):
     unicode = "🐌 mail."
     shortcode = ":snail: mail."
     image = (
         '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/> mail.'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #9
0
 def test_emoji_at_end_of_sentence_with_alternate_punctuation(self):
     unicode = "Emoji One's official mascot is 🐌!"
     shortcode = "Emoji One's official mascot is :snail:!"
     image = (
         'Emoji One\'s official mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/>!'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #10
0
 def test_single_unicode_char(self):
     unicode = "🐌"
     shortcode = ":snail:"
     image = (
         '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'
         + self.cache_bust_param
         + '"/>'
     )
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #11
0
def emoji_replace(text, autoescape=True):
    """
    Replaces Unicode and Shortcode emoji's with embedded images,
    using the Emojipy library

    Args:
        text: A string to be matched for shortcode and unicode emojis
        autoescape: Optional argument for autoescaping of input string before processing

    Returns:
        Safe text
    """
    # Escape text if it is not safe
    autoescape = autoescape and not isinstance(text, SafeData)
    if autoescape:
        text = escape(text)

    text = Emoji.unicode_to_image(text)
    text = Emoji.shortcode_to_image(text)

    return mark_safe(text)
Beispiel #12
0
 def test_emoji_at_start_of_sentence(self):
     unicode = '🐌 mail.'
     shortcode = ':snail: mail.'
     image = '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1F40C.png' + self.cache_bust_param + '"/> mail.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_start_of_sentence(self):
     unicode = '🐌 mail.'
     shortcode = ':snail: mail.'
     image = '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/> mail.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #14
0
 def test_emoji_inside_img_tag(self):
     unicode = 'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png" /> is Emoji One\'s official mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), unicode)
     self.assertEqual(Emoji.shortcode_to_image(unicode), unicode)
 def test_emoji_at_start_of_sentence_with_apostrophe(self):
     unicode = '🐌\'s are cool!'
     shortcode = ':snail:\'s are cool!'
     image = '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1F40C.png'+self.cache_bust_param+'"/>\'s are cool!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #16
0
 def test_emoji_inside_sentence_with_comma(self):
     unicode = 'The 🐌, is Emoji One\'s official mascot.'
     shortcode = 'The :snail:, is Emoji One\'s official mascot.'
     image = 'The <img class="emojione" alt="🐌" src="//cdn.jsdelivr.net/emojione/assets/png/1F40C.png'+self.cache_bust_param+'"/>, is Emoji One\'s official mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_inside_img_tag(self):
     unicode = 'The <img class="joypixels" alt="🐌" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f40c.png"/> was EmojiOne\'s original mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), unicode)
     self.assertEqual(Emoji.shortcode_to_image(unicode), unicode)
 def test_emoji_at_end_of_sentence_with_alternate_punctuation(self):
     unicode = 'EmojiOne\'s original mascot was 🐌!'
     shortcode = 'EmojiOne\'s original mascot was :snail:!'
     image = 'EmojiOne\'s original mascot was <img class="joypixels" alt="🐌" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f40c.png"/>!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_single_unicode_char(self):
     unicode = '🐌'
     shortcode = ':snail:'
     image = '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'+self.cache_bust_param+'"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
def shortcode_to_image(value, *args, **kwargs):
    return mark_safe(Emoji.shortcode_to_image(value, **kwargs))
Beispiel #21
0
 def test_emoji_at_end_of_sentence_with_preceeding_colon(self):
     unicode = 'EmojiOne\'s original mascot: 🐌'
     shortcode = 'EmojiOne\'s original mascot: :snail:'
     image = 'EmojiOne\'s original mascot: <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #22
0
 def test_emoji_at_end_of_sentence_with_alternate_punctuation(self):
     unicode = 'EmojiOne\'s original mascot is 🐌!'
     shortcode = 'EmojiOne\'s original mascot is :snail:!'
     image = 'EmojiOne\'s original mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_end_of_sentence(self):
     unicode = 'EmojiOne\'s original mascot is 🐌.'
     shortcode = 'EmojiOne\'s original mascot is :snail:.'
     image = 'EmojiOne\'s original mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_inside_sentence_with_comma(self):
     unicode = 'The 🐌, was EmojiOne\'s original mascot.'
     shortcode = 'The :snail:, was EmojiOne\'s original mascot.'
     image = 'The <img class="joypixels" alt="🐌" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f40c.png"/>, was EmojiOne\'s original mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_start_of_sentence_with_apostrophe(self):
     unicode = '🐌\'s are cool!'
     shortcode = ':snail:\'s are cool!'
     image = '<img class="joypixels" alt="🐌" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f40c.png"/>\'s are cool!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_inside_sentence_with_comma(self):
     unicode = 'The 🐌, is Emoji One\'s official mascot.'
     shortcode = 'The :snail:, is Emoji One\'s official mascot.'
     image = 'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'+self.cache_bust_param+'"/>, is Emoji One\'s official mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_end_of_sentence_with_preceeding_colon(self):
     unicode = 'EmojiOne\'s original mascot was: 🐌'
     shortcode = 'EmojiOne\'s original mascot was: :snail:'
     image = 'EmojiOne\'s original mascot was: <img class="joypixels" alt="🐌" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f40c.png"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_start_of_sentence_with_apostrophe(self):
     unicode = '🐌\'s are cool!'
     shortcode = ':snail:\'s are cool!'
     image = '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'+self.cache_bust_param+'"/>\'s are cool!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #29
0
 def test_single_unicode_char(self):
     unicode = '🐌'
     shortcode = ':snail:'
     image = '<img class="emojione" alt="🐌" src="//cdn.jsdelivr.net/emojione/assets/png/1F40C.png'+self.cache_bust_param+'"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_end_of_sentence_with_alternate_punctuation(self):
     unicode = 'Emoji One\'s official mascot is 🐌!'
     shortcode = 'Emoji One\'s official mascot is :snail:!'
     image = 'Emoji One\'s official mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'+self.cache_bust_param+'"/>!'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #31
0
def shortcode_to_image(text, **kwargs):
    return Emoji.shortcode_to_image(text, **kwargs)
 def test_emoji_at_end_of_sentence_with_preceeding_colon(self):
     unicode = 'Emoji One\'s official mascot: 🐌'
     shortcode = 'Emoji One\'s official mascot: :snail:'
     image = 'Emoji One\'s official mascot: <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png'+self.cache_bust_param+'"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_at_end_of_sentence(self):
     unicode = 'Emoji One\'s official mascot is 🐌.'
     shortcode = 'Emoji One\'s official mascot is :snail:.'
     image = 'Emoji One\'s official mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1F40C.png'+self.cache_bust_param+'"/>.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_inside_sentence(self):
     unicode = 'The 🐌 is EmojiOne\'s original mascot.'
     shortcode = 'The :snail: is EmojiOne\'s original mascot.'
     image     = 'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/> is EmojiOne\'s original mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
Beispiel #35
0
 def test_emoji_inside_object_tag(self):
     unicode = 'The <object class="emojione" data="//cdn.jsdelivr.net/emojione/assets/svg/1f40c.svg" type="image/svg+xml" standby="🐌">🐌</object> is Emoji One\'s official mascot'
     self.assertEqual(Emoji.unicode_to_image(unicode), unicode)
     self.assertEqual(Emoji.shortcode_to_image(unicode), unicode)
Beispiel #36
0
 def test_emoji_inside_sentence_with_comma(self):
     unicode = 'The 🐌, is EmojiOne\'s original mascot.'
     shortcode = 'The :snail:, is EmojiOne\'s original mascot.'
     image = 'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>, is EmojiOne\'s original mascot.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
def shortcode_to_image(text, **kwargs):
    return Emoji.shortcode_to_image(text, **kwargs)
Beispiel #38
0
 def test_single_unicode_char(self):
     unicode = '🐌'
     shortcode = ':snail:'
     image = '<img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/3.1/png/64/1f40c.png"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_inside_object_tag(self):
     unicode = 'The <object class="emojione" data="//cdn.jsdelivr.net/emojione/assets/svg/1f40c.svg" type="image/svg+xml" standby="🐌">🐌</object> is Emoji One\'s official mascot'
     self.assertEqual(Emoji.unicode_to_image(unicode), unicode)
     self.assertEqual(Emoji.shortcode_to_image(unicode), unicode)
 def test_single_unicode_char(self):
     unicode = '🐌'
     shortcode = ':snail:'
     image = '<img class="joypixels" alt="🐌" src="https://cdn.jsdelivr.net/joypixels/assets/4.5/png/64/1f40c.png"/>'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)
 def test_emoji_inside_img_tag(self):
     unicode = 'The <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1f40c.png" /> is Emoji One\'s official mascot.';
     self.assertEqual(Emoji.unicode_to_image(unicode), unicode)
     self.assertEqual(Emoji.shortcode_to_image(unicode), unicode)
Beispiel #42
0
 def test_emoji_at_end_of_sentence(self):
     unicode = 'Emoji One\'s official mascot is 🐌.'
     shortcode = 'Emoji One\'s official mascot is :snail:.'
     image = 'Emoji One\'s official mascot is <img class="emojione" alt="🐌" src="https://cdn.jsdelivr.net/emojione/assets/png/1F40C.png' + self.cache_bust_param + '"/>.'
     self.assertEqual(Emoji.unicode_to_image(unicode), image)
     self.assertEqual(Emoji.shortcode_to_image(shortcode), image)