File tree Expand file tree Collapse file tree 3 files changed +12
-18
lines changed Expand file tree Collapse file tree 3 files changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,3 @@ AllCops:
5
5
TargetRubyVersion : 2.3
6
6
Exclude :
7
7
- vendor/**/*
8
-
9
- Metrics/LineLength :
10
- Exclude :
11
- - spec/**/*
12
- - jekyll-mentions.gemspec
13
-
14
- Metrics/BlockLength :
15
- Exclude :
16
- - spec/**/*
Original file line number Diff line number Diff line change @@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
22
22
s . add_development_dependency "rake" , "~> 12.0"
23
23
s . add_development_dependency "rspec" , "~> 3.0"
24
- s . add_development_dependency "rubocop" , "~> 0.57.2 "
24
+ s . add_development_dependency "rubocop-jekyll " , "~> 0.3 "
25
25
end
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ class Mentions
8
8
GITHUB_DOT_COM = "https://github.com"
9
9
BODY_START_TAG = "<body"
10
10
11
- OPENING_BODY_TAG_REGEX = %r!<body(.*?)>\s *!
11
+ OPENING_BODY_TAG_REGEX = %r!<body(.*?)>\s *! . freeze
12
12
13
13
InvalidJekyllMentionConfig = Class . new ( Jekyll ::Errors ::FatalException )
14
14
@@ -17,6 +17,7 @@ class << self
17
17
def mentionify ( doc )
18
18
content = doc . output
19
19
return unless content . include? ( "@" )
20
+
20
21
src = mention_base ( doc . site . config )
21
22
if content . include? BODY_START_TAG
22
23
head , opener , tail = content . partition ( OPENING_BODY_TAG_REGEX )
@@ -28,6 +29,7 @@ def mentionify(doc)
28
29
doc . output = String . new ( head ) << opener << processed_markup << rest . join
29
30
else
30
31
return unless content =~ filter_regex
32
+
31
33
doc . output = filter_with_mention ( src ) . call ( content ) [ :output ] . to_s
32
34
end
33
35
end
@@ -93,13 +95,14 @@ def mentionable?(doc)
93
95
private
94
96
95
97
def filter_regex
96
- @filter_regex ||= begin
97
- Regexp . new (
98
- HTML ::Pipeline ::MentionFilter ::MentionPatterns [ mention_username_pattern ]
99
- )
100
- rescue TypeError
101
- %r!@\w +!
102
- end
98
+ @filter_regex ||=
99
+ begin
100
+ Regexp . new (
101
+ HTML ::Pipeline ::MentionFilter ::MentionPatterns [ mention_username_pattern ]
102
+ )
103
+ rescue TypeError
104
+ %r!@\w +!
105
+ end
103
106
end
104
107
105
108
def default_mention_base
You can’t perform that action at this time.
0 commit comments