Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uppercase chars in username #33

Merged
merged 3 commits into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/jekyll-mentions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def mentionify(doc)
def filter_with_mention(src)
filters[src] ||= HTML::Pipeline.new([
HTML::Pipeline::MentionFilter
], { :base_url => src })
], { :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.
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/_docs/dont_touch_me.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Don't Touch Me
---
test @test test
test @TestUser test
2 changes: 1 addition & 1 deletion spec/fixtures/_docs/file.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---

test @test test
test @TestUser test
2 changes: 1 addition & 1 deletion spec/fixtures/_docs/with_liquid.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
title: With Liquid
---

test @test test <a href="{{ page.url }}">{{ page.path }}</a>
test @TestUser test <a href="{{ page.url }}">{{ page.path }}</a>
2 changes: 1 addition & 1 deletion spec/fixtures/_posts/2016-01-01-awesome-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
title: I'm a post
---

test @test test
test @TestUser test
4 changes: 2 additions & 2 deletions spec/fixtures/_posts/2016-03-08-code-block.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

```ruby
def test_output
"test @test test"
"test @TestUser test"
end
```

test @test test
test @TestUser test
2 changes: 1 addition & 1 deletion spec/fixtures/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ layout: default
title: I'm a page
---

test @test test
test @TestUser test
2 changes: 1 addition & 1 deletion spec/fixtures/leave-liquid-alone.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
title: don't mangle that liquid plz
---

test @test test<a href="{{ test }}">test</a>
test @TestUser test<a href="{{ test }}">test</a>
2 changes: 1 addition & 1 deletion spec/fixtures/mentioned-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
title: mention me but don't eff my markdown
---

test @test test
test @TestUser test
> test
2 changes: 1 addition & 1 deletion spec/fixtures/non-mentioned.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
title: don't mention me bro
---

test test test
test TestUser test
> test
2 changes: 1 addition & 1 deletion spec/fixtures/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
title: I'm a page
---

test @test test
test @TestUser test
6 changes: 3 additions & 3 deletions spec/mentions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"https://github.com/test\" class=\"user-mention\">@test</a> test" }
let(:unrendered) { "test @TestUser test" }
let(:result) { "test <a href=\"https://github.com/TestUser\" class=\"user-mention\">@TestUser</a> test" }

let(:posts) { site.posts.docs.sort.reverse }
let(:basic_post) { find_by_title(posts, "I'm a post") }
Expand Down Expand Up @@ -51,7 +51,7 @@ def para(content)

it "doesn't replace mentions in a code block" do
expect(complex_post.output).to include(
"<span class=\"s2\">\"test @test test\"</span>"
"<span class=\"s2\">\"test @TestUser test\"</span>"
)
expect(complex_post.output).to include(result)
end
Expand Down