diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index afb6136..f9125e0 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -47,7 +47,6 @@ module Gitlab # Note: reference links will only be generated if @project is set def gfm(text, html_options = {}) return text if text.nil? - return text if @project.nil? @html_options = html_options @@ -78,8 +77,11 @@ module Gitlab # # text - Text to parse # + # Note: reference links will only be generated if @project is set + # # Returns parsed text def parse(text) + # parse reference links text.gsub!(REFERENCE_PATTERN) do |match| prefix = $1 || '' reference = $2 @@ -91,8 +93,9 @@ module Gitlab else match end - end + end if @project + # 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) diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 3e7a02c..4dd3802 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -247,6 +247,11 @@ describe GitlabMarkdownHelper do it "ignores invalid emoji" do gfm(":invalid-emoji:").should_not match(/