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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c616ac60e98b103ea1923bfb61a2b8dba81a8360
4
- data.tar.gz: 4437c013d34d01d707597071dc8881e70d095c43
3
+ metadata.gz: 30c863a25be5728522fd0748c93b43e52671a87e
4
+ data.tar.gz: 27b24fc7b69ab3e61b3e47548d398c737ac8b40e
5
5
  SHA512:
6
- metadata.gz: 39edeccac9b7c4b68c7f2d098753e188869fefe42f0ed8e999775d7db4cd05015943db2f64452c7d4341bbafeb4d1c1f31fed606a3c0264d3002d36809e4ba51
7
- data.tar.gz: 91c31e3751ccae3c4f248ea74e1aaed8a9126d0b8eda1949042e196ee3d9b56f9fc091dd09afed92a68da6f6c190df5a0de143467eb19d441e1358cf2851860c
6
+ metadata.gz: 51f484782bbbd640d5f0f985bf494280f0b7e28f0b82ab88a0983a8c24f8b201278d780a090afede93c1a99bcd299506c2787333ac8bc2bee194bbc89a7c2ead
7
+ data.tar.gz: 362eed29b7aa60c05900135593163d3def6dbc2d47a42c509259a50bf2772198cbffdc7da9141c630f45caee8ea7ecd1e1e592c1a96c039ec3d791b319ee1594
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.11.3
2
+ - Ignore menton in blockquote element
3
+
1
4
  ## 0.11.2
2
5
  - Support video element on `SCRIPTABLE_RULE`
3
6
 
@@ -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|
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Markdown
3
- VERSION = "0.11.2"
3
+ VERSION = "0.11.3"
4
4
  end
5
5
  end
@@ -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.2
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: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemoji