qiita-markdown 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of qiita-markdown might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/qiita/markdown/filters/mention.rb +17 -0
- data/lib/qiita/markdown/version.rb +1 -1
- data/spec/qiita/markdown/processor_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c863a25be5728522fd0748c93b43e52671a87e
|
4
|
+
data.tar.gz: 27b24fc7b69ab3e61b3e47548d398c737ac8b40e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51f484782bbbd640d5f0f985bf494280f0b7e28f0b82ab88a0983a8c24f8b201278d780a090afede93c1a99bcd299506c2787333ac8bc2bee194bbc89a7c2ead
|
7
|
+
data.tar.gz: 362eed29b7aa60c05900135593163d3def6dbc2d47a42c509259a50bf2772198cbffdc7da9141c630f45caee8ea7ecd1e1e592c1a96c039ec3d791b319ee1594
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,8 @@ module Qiita
|
|
6
6
|
#
|
7
7
|
# You can pass :allowed_usernames context to limit mentioned usernames.
|
8
8
|
class Mention < HTML::Pipeline::MentionFilter
|
9
|
+
IGNORE_PARENTS = ::HTML::Pipeline::MentionFilter::IGNORE_PARENTS + Set["blockquote"]
|
10
|
+
|
9
11
|
MentionPattern = /
|
10
12
|
(?:^|\W)
|
11
13
|
@((?>[\w][\w-]{0,30}\w(?:@github)?))
|
@@ -18,6 +20,21 @@ module Qiita
|
|
18
20
|
)
|
19
21
|
/ix
|
20
22
|
|
23
|
+
# @note Override to use another IGNORE_PARENTS
|
24
|
+
def call
|
25
|
+
result[:mentioned_usernames] ||= []
|
26
|
+
|
27
|
+
doc.search(".//text()").each do |node|
|
28
|
+
content = node.to_html
|
29
|
+
next unless content.include?("@")
|
30
|
+
next if has_ancestor?(node, IGNORE_PARENTS)
|
31
|
+
html = mention_link_filter(content, base_url, info_url, username_pattern)
|
32
|
+
next if html == content
|
33
|
+
node.replace(html)
|
34
|
+
end
|
35
|
+
doc
|
36
|
+
end
|
37
|
+
|
21
38
|
# @note Override to use customized MentionPattern and allowed_usernames logic.
|
22
39
|
def mention_link_filter(text, _, _, _)
|
23
40
|
text.gsub(MentionPattern) do |match|
|
@@ -345,6 +345,20 @@ describe Qiita::Markdown::Processor do
|
|
345
345
|
end
|
346
346
|
end
|
347
347
|
|
348
|
+
context "with mention in blockquote" do
|
349
|
+
let(:markdown) do
|
350
|
+
"> @alice"
|
351
|
+
end
|
352
|
+
|
353
|
+
it "does not replace mention with link" do
|
354
|
+
should include(<<-EOS.strip_heredoc.rstrip)
|
355
|
+
<blockquote>
|
356
|
+
<p>@alice</p>
|
357
|
+
</blockquote>
|
358
|
+
EOS
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
348
362
|
context "with mention to user whose name starts and ends with underscore" do
|
349
363
|
let(:markdown) do
|
350
364
|
"@_alice_"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemoji
|