From 965917bbf7477a0711abbcb63365888efccd0a0e Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Dec 2017 14:50:12 -0600 Subject: [PATCH 1/2] Add failing test --- spec/gist_tag_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/gist_tag_spec.rb b/spec/gist_tag_spec.rb index f04618c..beaac34 100644 --- a/spec/gist_tag_spec.rb +++ b/spec/gist_tag_spec.rb @@ -49,17 +49,25 @@ end context "with file specified" do - before { stub_request(:get, "https://gist.githubusercontent.com/#{gist}/raw/#{filename}").to_return(:body => http_output) } + before { stub_request(:get, %r!https://gist.githubusercontent.com/#{gist}/raw/.*!).to_return(:body => http_output) } let(:gist) { "mattr-/24081a1d93d2898ecf0f" } let(:filename) { "myfile.ext" } let(:content) { "{% gist #{gist} #{filename} %}" } it "produces the correct script tag" do - expect(output).to match(%r!!) + end + end end context "with variable gist id" do From 55bbb0d6cf8ba4f8178a31cfecea9ba0f46ebc48 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Mon, 4 Dec 2017 14:56:44 -0600 Subject: [PATCH 2/2] Strip special characters --- lib/jekyll-gist/gist_tag.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/jekyll-gist/gist_tag.rb b/lib/jekyll-gist/gist_tag.rb index c265063..2b02af8 100644 --- a/lib/jekyll-gist/gist_tag.rb +++ b/lib/jekyll-gist/gist_tag.rb @@ -11,6 +11,7 @@ module Jekyll module Gist class GistTag < Liquid::Tag def render(context) + @special_characters = "#" @encoding = context.registers[:site].config["encoding"] || "utf-8" @settings = context.registers[:site].config["gist"] if (tag_contents = determine_arguments(@markup.strip)) @@ -22,6 +23,7 @@ def render(context) if context_contains_key?(context, filename) filename = context[filename] end + filename.delete!(@special_characters) noscript_tag = gist_noscript_tag(gist_id, filename) script_tag = gist_script_tag(gist_id, filename) "#{noscript_tag}#{script_tag}"