diff --git a/lib/html/pipeline/emoji_filter.rb b/lib/html/pipeline/emoji_filter.rb index 78843376..343e6bc6 100644 --- a/lib/html/pipeline/emoji_filter.rb +++ b/lib/html/pipeline/emoji_filter.rb @@ -18,7 +18,7 @@ def call search_text_nodes(doc).each do |node| content = node.to_html next unless content.include?(':') - next if has_ancestor?(node, %w(pre code)) + next if has_ancestor?(node, %w(pre code tt)) html = emoji_image_filter(content) next if html == content node.replace(html) diff --git a/test/html/pipeline/emoji_filter_test.rb b/test/html/pipeline/emoji_filter_test.rb index 298775ed..14d5c991 100644 --- a/test/html/pipeline/emoji_filter_test.rb +++ b/test/html/pipeline/emoji_filter_test.rb @@ -33,4 +33,25 @@ def test_custom_asset_path doc = filter.call assert_match "https://foo.com/%2B1.png", doc.search('img').attr('src').value end + + def test_not_emojify_in_code_tags + body = ":shipit:" + filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'}) + doc = filter.call + assert_equal body, doc.to_html + end + + def test_not_emojify_in_tt_tags + body = ":shipit:" + filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'}) + doc = filter.call + assert_equal body, doc.to_html + end + + def test_not_emojify_in_pre_tags + body = "
:shipit:
" + filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'}) + doc = filter.call + assert_equal body, doc.to_html + end end