Commit ad7fcc7b authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Use monospaced font for MR diff commit link ref on GFM

parent 07de43a7
---
title: Use monospaced font for MR diff commit link ref on GFM
merge_request:
author:
type: other
......@@ -25,7 +25,10 @@ module Banzai
extras = super
if commit_ref = object_link_commit_ref(object, matches)
return extras.unshift(commit_ref)
klass = reference_class(:commit, tooltip: false)
commit_ref_tag = %(<span class="#{klass}">#{commit_ref}</span>)
return extras.unshift(commit_ref_tag)
end
path = matches[:path] if matches.names.include?("path")
......
......@@ -65,8 +65,12 @@ module Banzai
context[:skip_project_check]
end
def reference_class(type)
"gfm gfm-#{type} has-tooltip"
def reference_class(type, tooltip: true)
gfm_klass = "gfm gfm-#{type}"
return gfm_klass unless tooltip
"#{gfm_klass} has-tooltip"
end
# Ensure that a :project key exists in context
......
......@@ -210,6 +210,13 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
.to eq reference
end
it 'commit ref tag is valid' do
doc = reference_filter("See #{reference}")
commit_ref_tag = doc.css('a').first.css('span.gfm.gfm-commit')
expect(commit_ref_tag.text).to eq(commit.short_id)
end
it 'has valid text' do
doc = reference_filter("See #{reference}")
......
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