diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-12 21:51:15 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-12 21:51:15 +0300 |
commit | 66dd61ef0f1f98f860bdef5aa2cdb1c6f2e1f83f (patch) | |
tree | 0a2458257370ba7200ac8ae8fc33d4d6ac6df912 | |
parent | fba6141746821261287be0f4332814697f99e5ae (diff) | |
parent | 7a01d0cc74eac15475f4c2245447c7f751744219 (diff) | |
download | gitlab-ce-66dd61ef0f1f98f860bdef5aa2cdb1c6f2e1f83f.tar.gz |
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
-rw-r--r-- | lib/redcarpet/render/gitlab_html.rb | 12 | ||||
-rw-r--r-- | spec/helpers/gitlab_markdown_helper_spec.rb | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index c3378d6a18f..54d740908d5 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -10,6 +10,17 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML super options end + # If project has issue number 39, apostrophe will be linked in + # regular text to the issue as Redcarpet will convert apostrophe to + # #39; + # We replace apostrophe with right single quote before Redcarpet + # does the processing and put the apostrophe back in postprocessing. + # This only influences regular text, code blocks are untouched. + def normal_text(text) + return text unless text.present? + text.gsub("'", "’") + end + def block_code(code, language) # New lines are placed to fix an rendering issue # with code wrapped inside <h1> tag for next case: @@ -44,6 +55,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML end def postprocess(full_document) + full_document.gsub!("’", "'") unless @template.instance_variable_get("@project_wiki") || @project.nil? full_document = h.create_relative_links(full_document) end diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 26908abc30a..328942d32b0 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -530,6 +530,24 @@ describe GitlabMarkdownHelper do markdown(actual).should match(%r{<li>light by <a.+>@#{member.user.username}</a></li>}) end + it "should not link the apostrophe to issue 39" do + project.team << [user, :master] + project.issues.stub(:where).with(iid: '39').and_return([issue]) + + actual = "Yes, it is @#{member.user.username}'s task." + expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/ + markdown(actual).should match(expected) + end + + it "should not link the apostrophe to issue 39 in code blocks" do + project.team << [user, :master] + project.issues.stub(:where).with(iid: '39').and_return([issue]) + + actual = "Yes, `it is @#{member.user.username}'s task.`" + expected = /Yes, <code>it is @gfm\'s task.<\/code>/ + markdown(actual).should match(expected) + end + it "should handle references in <em>" do actual = "Apply _!#{merge_request.iid}_ ASAP" |