html-pipeline-nico_link 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669691f7e24690e1d17ddf78494e03af4e7e9532
|
4
|
+
data.tar.gz: bba05ef827ed06f7cd4565955fc117fc6ea875f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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}/,
|
@@ -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
|