From 3d861e8ef528b340a2e450c1cad243dec03623ee Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Tue, 12 Dec 2017 12:33:50 +1100 Subject: [PATCH 1/4] Pass through symlink info See github/linguist#3946 --- lib/github/markup.rb | 17 +++++++++-------- test/markup_test.rb | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/github/markup.rb b/lib/github/markup.rb index 3f363555..a0a9ff0c 100644 --- a/lib/github/markup.rb +++ b/lib/github/markup.rb @@ -40,10 +40,11 @@ def preload! end end - def render(filename, content = nil) + def render(filename, content = nil, symlink = nil) content ||= File.read(filename) + symlink = (File.symlink?(filename) rescue false) if symlink.nil? - if impl = renderer(filename, content) + if impl = renderer(filename, content, symlink) impl.render(filename, content) else content @@ -79,20 +80,20 @@ def command(symbol, command, regexp, languages, name, &block) markup_impl(symbol, CommandImplementation.new(regexp, languages, command, name, &block)) end - def can_render?(filename, content) - !!renderer(filename, content) + def can_render?(filename, content, symlink = false) + !!renderer(filename, content, symlink) end - def renderer(filename, content) - language = language(filename, content) + def renderer(filename, content, symlink = false) + language = language(filename, content, symlink) markup_impls.find { |impl| impl.match?(filename, language) } end - def language(filename, content) + def language(filename, content, symlink = false) if defined?(::Linguist) - blob = Linguist::Blob.new(filename, content) + blob = Linguist::Blob.new(filename, content, symlink: symlink) return Linguist.detect(blob, allow_empty: true) end end diff --git a/test/markup_test.rb b/test/markup_test.rb index 81a7d1e8..8e02ed21 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -104,7 +104,7 @@ def test_raises_error_if_command_exits_non_zero GitHub::Markup.command(:doesntmatter, 'test/fixtures/fail.sh', /fail/, ['Java'], 'fail') assert GitHub::Markup.can_render?('README.java', 'stop swallowing errors') begin - GitHub::Markup.render('README.java', "stop swallowing errors") + GitHub::Markup.render('README.java', "stop swallowing errors", false) rescue GitHub::Markup::CommandError => e assert_equal "failure message", e.message else From f6484c4e3db74396809fad60c2b0a33bc046a132 Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Tue, 30 Jan 2018 12:16:32 +1100 Subject: [PATCH 2/4] pull in linguist 6 --- github-markup.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-markup.gemspec b/github-markup.gemspec index 93b00b1c..f599cd2d 100644 --- a/github-markup.gemspec +++ b/github-markup.gemspec @@ -23,5 +23,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'sanitize', '~> 2.1', '>= 2.1.0' s.add_development_dependency 'nokogiri', '1.6.8.1' s.add_development_dependency 'nokogiri-diff', '~> 0.2.0' - s.add_development_dependency "github-linguist", "~> 5.0", ">= 5.0.8" + s.add_development_dependency "github-linguist", "~> 6.0" end From 31ae286e13e1a8c21e0824399f3781f190d0dd57 Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Tue, 30 Jan 2018 12:27:33 +1100 Subject: [PATCH 3/4] wikicloth doesn't pin dependencies so we have to --- github-markup.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/github-markup.gemspec b/github-markup.gemspec index f599cd2d..bf05db18 100644 --- a/github-markup.gemspec +++ b/github-markup.gemspec @@ -24,4 +24,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'nokogiri', '1.6.8.1' s.add_development_dependency 'nokogiri-diff', '~> 0.2.0' s.add_development_dependency "github-linguist", "~> 6.0" + s.add_development_dependency "twitter-text", "~> 1.14" end From 6704f82a258ccd9cd2a19f1ec90b8ecd460cb140 Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Tue, 30 Jan 2018 12:37:16 +1100 Subject: [PATCH 4/4] try here --- Gemfile | 1 + github-markup.gemspec | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4a84781d..a5a58995 100644 --- a/Gemfile +++ b/Gemfile @@ -10,5 +10,6 @@ gem "rdoc", "~>3.6" gem "org-ruby", "= 0.9.9" gem "creole", "~>0.3.6" gem "wikicloth", "=0.8.3" +gem "twitter-text", "~> 1.14" gem "asciidoctor", "= 1.5.6.1" gem "rake" diff --git a/github-markup.gemspec b/github-markup.gemspec index bf05db18..f599cd2d 100644 --- a/github-markup.gemspec +++ b/github-markup.gemspec @@ -24,5 +24,4 @@ Gem::Specification.new do |s| s.add_development_dependency 'nokogiri', '1.6.8.1' s.add_development_dependency 'nokogiri-diff', '~> 0.2.0' s.add_development_dependency "github-linguist", "~> 6.0" - s.add_development_dependency "twitter-text", "~> 1.14" end