Commit 534bd5a2 authored by Riyad Preukschas's avatar Riyad Preukschas

Fix emoji generation and styling

parent bd60a4ed
...@@ -692,3 +692,9 @@ h1.http_status_code { ...@@ -692,3 +692,9 @@ h1.http_status_code {
} }
} }
} }
img.emoji {
height: 20px;
vertical-align: middle;
width: 20px;
}
...@@ -25,18 +25,6 @@ module Gitlab ...@@ -25,18 +25,6 @@ module Gitlab
# >> gfm(":trollface:") # >> gfm(":trollface:")
# => "<img alt=\":trollface:\" class=\"emoji\" src=\"/images/trollface.png" title=\":trollface:\" /> # => "<img alt=\":trollface:\" class=\"emoji\" src=\"/images/trollface.png" title=\":trollface:\" />
module Markdown module Markdown
REFERENCE_PATTERN = %r{
(\W)? # Prefix (1)
( # Reference (2)
@([\w\._]+) # User name (3)
|[#!$](\d+) # Issue/MR/Snippet ID (4)
|([\h]{6,40}) # Commit ID (5)
)
(\W)? # Suffix (6)
}x.freeze
EMOJI_PATTERN = %r{(:(\S+):)}.freeze
attr_reader :html_options attr_reader :html_options
# Public: Parse the provided text with GitLab-Flavored Markdown # Public: Parse the provided text with GitLab-Flavored Markdown
...@@ -92,6 +80,16 @@ module Gitlab ...@@ -92,6 +80,16 @@ module Gitlab
text text
end end
REFERENCE_PATTERN = %r{
(\W)? # Prefix (1)
( # Reference (2)
@([\w\._]+) # User name (3)
|[#!$](\d+) # Issue/MR/Snippet ID (4)
|([\h]{6,40}) # Commit ID (5)
)
(\W)? # Suffix (6)
}x.freeze
def parse_references(text) def parse_references(text)
# parse reference links # parse reference links
text.gsub!(REFERENCE_PATTERN) do |match| text.gsub!(REFERENCE_PATTERN) do |match|
...@@ -111,11 +109,13 @@ module Gitlab ...@@ -111,11 +109,13 @@ module Gitlab
end end
end end
EMOJI_PATTERN = %r{(:(\S+):)}.freeze
def parse_emoji(text) def parse_emoji(text)
# parse emoji # parse emoji
text.gsub!(EMOJI_PATTERN) do |match| text.gsub!(EMOJI_PATTERN) do |match|
if valid_emoji?($2) if valid_emoji?($2)
image_tag("emoji/#{$2}.png", size: "20x20", class: 'emoji', title: $1, alt: $1) image_tag("emoji/#{$2}.png", class: 'emoji', title: $1, alt: $1)
else else
match match
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment