html-pipeline-nico_link 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d6aacabfa73258fb316f0956d73ecb93fe32faf
4
- data.tar.gz: ebd83dd3a62b68048b95f93965db64667a10a30f
3
+ metadata.gz: 669691f7e24690e1d17ddf78494e03af4e7e9532
4
+ data.tar.gz: bba05ef827ed06f7cd4565955fc117fc6ea875f5
5
5
  SHA512:
6
- metadata.gz: 1cc4850ae7eb876e625f2532cfe3c958e00c7678e56d17aef373be8e53aef0e77bde6cb1c9b9419cea1303e74b62f5b9e8d629184fd462937c3489a6a9983149
7
- data.tar.gz: 017efd4507c40b71fed35a243b41a1e402c29e27bf7bd21ea4c3288ca375eec5378fb9ea1264dcbb2d97121167d1e6184c48008db1e94961ae4c4d9fd37ef248
6
+ metadata.gz: 3f66c70f51d7105c63d271d153e29d66196e099a64a889695b432bdedbe93acada349ceec426e04e544abda6398de9ceae27bf0437d04a2398a18102a8368b05
7
+ data.tar.gz: 968356e76338603d9fd485a839208b152078a003b18fb715954b03a1354857ef7d5530e214eb05deb4a5e9a527ef6c4405f714b4463e8b32a100ac3fcdf9d1f6
@@ -11,6 +11,7 @@ module HTML
11
11
 
12
12
  def call
13
13
  doc.search('text()').each do |node|
14
+ next if has_ancestor?(node, IGNORE_PARENTS)
14
15
  content = node.to_html
15
16
  has_prev_node = !!(node.previous_element)
16
17
  html = apply_filter(content, has_prev_node)
@@ -55,6 +56,8 @@ module HTML
55
56
  /ix
56
57
  end
57
58
 
59
+ IGNORE_PARENTS = %w[pre code a style script].to_set
60
+
58
61
  DEFAULT_PATTERNS = [
59
62
  {
60
63
  pattern: /(?:sm|nm|so|ca|ax|yo|nl|ig|na|cw|z[a-e]|om|sk|yk)\d{1,14}/,
@@ -1,7 +1,7 @@
1
1
  module HTML
2
2
  class Pipeline
3
3
  module NicoLink
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
  end
7
7
  end
@@ -36,4 +36,9 @@ describe 'NicoLinkFilter' do
36
36
  let(:text) { '<b>hoge</b> im5678' }
37
37
  it { expect(subject).to eq '<b>hoge</b> <a href="http://seiga.nicovideo.jp/seiga/im5678">im5678</a>' }
38
38
  end
39
+
40
+ context '<a href="http://www.nicovideo.jp/watch/sm9">http://www.nicovideo.jp/watch/sm9</a>' do
41
+ let(:text) { '<a href="http://www.nicovideo.jp/watch/sm9">http://www.nicovideo.jp/watch/sm9</a>' }
42
+ it { expect(subject).to eq '<a href="http://www.nicovideo.jp/watch/sm9">http://www.nicovideo.jp/watch/sm9</a>' }
43
+ end
39
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-nico_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ru/MuckRu