From 534bd5a268bc3409db1352198222275ff844316d Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 16 Nov 2012 23:25:07 +0100 Subject: [PATCH] Fix emoji generation and styling --- app/assets/stylesheets/common.scss | 6 ++++++ lib/gitlab/markdown.rb | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 738ec2bf1dc..44bfb619ead 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -692,3 +692,9 @@ h1.http_status_code { } } } + +img.emoji { + height: 20px; + vertical-align: middle; + width: 20px; +} diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index ee0ee05c3be..23f408c697c 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -25,18 +25,6 @@ module Gitlab # >> gfm(":trollface:") # => "\":trollface:\" 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 # Public: Parse the provided text with GitLab-Flavored Markdown @@ -92,6 +80,16 @@ module Gitlab text 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) # parse reference links text.gsub!(REFERENCE_PATTERN) do |match| @@ -111,11 +109,13 @@ module Gitlab end end + EMOJI_PATTERN = %r{(:(\S+):)}.freeze + def parse_emoji(text) # parse emoji text.gsub!(EMOJI_PATTERN) do |match| 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 match end