From c03600a5ca6e00e4f84356817929054c5a8226ef Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 8 Jun 2016 07:35:39 +0900 Subject: [PATCH 1/2] Allow uppercase chars in username --- lib/jekyll-mentions.rb | 2 +- spec/fixtures/_docs/dont_touch_me.txt | 2 +- spec/fixtures/_docs/file.md | 2 +- spec/fixtures/_docs/with_liquid.md | 2 +- spec/fixtures/_posts/2016-01-01-awesome-post.md | 2 +- spec/fixtures/_posts/2016-03-08-code-block.md | 4 ++-- spec/fixtures/index.md | 2 +- spec/fixtures/leave-liquid-alone.md | 2 +- spec/fixtures/mentioned-markdown.md | 2 +- spec/fixtures/non-mentioned.md | 2 +- spec/fixtures/test.json | 2 +- spec/mentions_spec.rb | 6 +++--- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/jekyll-mentions.rb b/lib/jekyll-mentions.rb index 8fb7b2b..ffacf04 100644 --- a/lib/jekyll-mentions.rb +++ b/lib/jekyll-mentions.rb @@ -31,7 +31,7 @@ def mentionify(doc) def filter_with_mention(src) filters[src] ||= HTML::Pipeline.new([ HTML::Pipeline::MentionFilter - ], { :base_url => src }) + ], { :base_url => src , :username_pattern => /#{HTML::Pipeline::MentionFilter::UsernamePattern.source}/i }) end # Public: Filters hash where the key is the mention base URL. diff --git a/spec/fixtures/_docs/dont_touch_me.txt b/spec/fixtures/_docs/dont_touch_me.txt index 3e8ceb9..f3518cf 100644 --- a/spec/fixtures/_docs/dont_touch_me.txt +++ b/spec/fixtures/_docs/dont_touch_me.txt @@ -1,4 +1,4 @@ --- title: Don't Touch Me --- -test @test test +test @TestUser test diff --git a/spec/fixtures/_docs/file.md b/spec/fixtures/_docs/file.md index 20276e7..3fb74b2 100644 --- a/spec/fixtures/_docs/file.md +++ b/spec/fixtures/_docs/file.md @@ -1,4 +1,4 @@ --- --- -test @test test +test @TestUser test diff --git a/spec/fixtures/_docs/with_liquid.md b/spec/fixtures/_docs/with_liquid.md index b5d2114..986eb15 100644 --- a/spec/fixtures/_docs/with_liquid.md +++ b/spec/fixtures/_docs/with_liquid.md @@ -2,4 +2,4 @@ title: With Liquid --- -test @test test {{ page.path }} +test @TestUser test {{ page.path }} diff --git a/spec/fixtures/_posts/2016-01-01-awesome-post.md b/spec/fixtures/_posts/2016-01-01-awesome-post.md index 7e88809..df4f654 100644 --- a/spec/fixtures/_posts/2016-01-01-awesome-post.md +++ b/spec/fixtures/_posts/2016-01-01-awesome-post.md @@ -2,4 +2,4 @@ title: I'm a post --- -test @test test +test @TestUser test diff --git a/spec/fixtures/_posts/2016-03-08-code-block.md b/spec/fixtures/_posts/2016-03-08-code-block.md index 1573e73..159fc2c 100644 --- a/spec/fixtures/_posts/2016-03-08-code-block.md +++ b/spec/fixtures/_posts/2016-03-08-code-block.md @@ -3,8 +3,8 @@ ```ruby def test_output - "test @test test" + "test @TestUser test" end ``` -test @test test +test @TestUser test diff --git a/spec/fixtures/index.md b/spec/fixtures/index.md index 68e15e5..748eed9 100644 --- a/spec/fixtures/index.md +++ b/spec/fixtures/index.md @@ -3,4 +3,4 @@ layout: default title: I'm a page --- -test @test test +test @TestUser test diff --git a/spec/fixtures/leave-liquid-alone.md b/spec/fixtures/leave-liquid-alone.md index 0bd1807..46a3f9d 100644 --- a/spec/fixtures/leave-liquid-alone.md +++ b/spec/fixtures/leave-liquid-alone.md @@ -2,4 +2,4 @@ title: don't mangle that liquid plz --- -test @test testtest \ No newline at end of file +test @TestUser testtest \ No newline at end of file diff --git a/spec/fixtures/mentioned-markdown.md b/spec/fixtures/mentioned-markdown.md index 1aff6fe..ce1b833 100644 --- a/spec/fixtures/mentioned-markdown.md +++ b/spec/fixtures/mentioned-markdown.md @@ -2,5 +2,5 @@ title: mention me but don't eff my markdown --- -test @test test +test @TestUser test > test \ No newline at end of file diff --git a/spec/fixtures/non-mentioned.md b/spec/fixtures/non-mentioned.md index def0fee..faddbc0 100644 --- a/spec/fixtures/non-mentioned.md +++ b/spec/fixtures/non-mentioned.md @@ -2,5 +2,5 @@ title: don't mention me bro --- -test test test +test TestUser test > test \ No newline at end of file diff --git a/spec/fixtures/test.json b/spec/fixtures/test.json index 5f115f2..4cbafc2 100644 --- a/spec/fixtures/test.json +++ b/spec/fixtures/test.json @@ -2,4 +2,4 @@ title: I'm a page --- -test @test test \ No newline at end of file +test @TestUser test \ No newline at end of file diff --git a/spec/mentions_spec.rb b/spec/mentions_spec.rb index e7e7c19..f615e0e 100644 --- a/spec/mentions_spec.rb +++ b/spec/mentions_spec.rb @@ -15,8 +15,8 @@ let(:mentions) { described_class } let(:default_src) { "https://github.com" } let(:site) { Jekyll::Site.new(configs) } - let(:unrendered) { "test @test test" } - let(:result) { "test @test test" } + let(:unrendered) { "test @TestUser test" } + let(:result) { "test @TestUser test" } let(:posts) { site.posts.docs.sort.reverse } let(:basic_post) { find_by_title(posts, "I'm a post") } @@ -51,7 +51,7 @@ def para(content) it "doesn't replace mentions in a code block" do expect(complex_post.output).to include( - "\"test @test test\"" + "\"test @TestUser test\"" ) expect(complex_post.output).to include(result) end From 7ba93dfc5409800ca293bc5f09225de318550328 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 8 Jun 2016 18:19:36 +0900 Subject: [PATCH 2/2] Fixup --- lib/jekyll-mentions.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-mentions.rb b/lib/jekyll-mentions.rb index ffacf04..49eb36c 100644 --- a/lib/jekyll-mentions.rb +++ b/lib/jekyll-mentions.rb @@ -31,7 +31,11 @@ def mentionify(doc) def filter_with_mention(src) filters[src] ||= HTML::Pipeline.new([ HTML::Pipeline::MentionFilter - ], { :base_url => src , :username_pattern => /#{HTML::Pipeline::MentionFilter::UsernamePattern.source}/i }) + ], { :base_url => src , :username_pattern => mention_username_pattern }) + end + + def mention_username_pattern + Regexp.new(HTML::Pipeline::MentionFilter::UsernamePattern.source, Regexp::IGNORECASE) end # Public: Filters hash where the key is the mention base URL.