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

Don't check twice if there is a ':' in content (EmojiFilter) #141

Merged
merged 1 commit into from
Sep 15, 2014
Merged
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
4 changes: 1 addition & 3 deletions lib/html/pipeline/emoji_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EmojiFilter < Filter
def call
doc.search('text()').each do |node|
content = node.to_html
next if !content.include?(':')
next unless content.include?(':')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to back this change out, but for future reference, keep PR's focused to what you're trying to solve to make code reviews easier 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this change, because it was directly related to the refactored LOC. I should have promoted this change more clearly in the PR description. Thank's fore merging anyway 🍻

next if has_ancestor?(node, %w(pre code))
html = emoji_image_filter(content)
next if html == content
Expand All @@ -38,8 +38,6 @@ def validate
#
# Returns a String with :emoji: replaced with images.
def emoji_image_filter(text)
return text unless text.include?(':')

text.gsub(emoji_pattern) do |match|
name = $1
"<img class='emoji' title=':#{name}:' alt=':#{name}:' src='#{emoji_url(name)}' height='20' width='20' align='absmiddle' />"
Expand Down