Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<tt> tags are not skipped by EmojiFilter #147

Merged
merged 1 commit into from
Oct 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/html/pipeline/emoji_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions test/html/pipeline/emoji_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<code>:shipit:</code>"
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 = "<tt>:shipit:</tt>"
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 = "<pre>:shipit:</pre>"
filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'})
doc = filter.call
assert_equal body, doc.to_html
end
end