html-pipeline-linkify_github 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/lib/html/pipeline/linkify_github.rb +7 -6
- data/lib/html/pipeline/linkify_github/version.rb +1 -1
- data/test/linkify_github_integration_test.rb +11 -1
- data/test/linkify_github_test.rb +1 -1
- 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: 6ffe55eb51973c6e4aeb83b1313e2b59ad71940a
|
4
|
+
data.tar.gz: 8a8edc700201c6ea6f21b9ee819a74d53c239e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc7fd9cf12c8a39ecf1a51024ae2264b15a6938e05e568b6f2e01e5b7b042610db7a1caab3328d641fcaa6e82f29bbffde1c38cde14c98eaf61a4f45f533b7a
|
7
|
+
data.tar.gz: 44938bffae471376d7917591f75b3d2737eadd09f16d7941a95b0f7c8ecf2c6c2cf0a20292420dd3ae8b448817eae669fb27558fe402db12d0ee53fd06824783
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 1.0.2 - 2015.10.20
|
6
|
+
|
7
|
+
- Fix children tags got removed when converting urls. [#4](https://github.com/jollygoodcode/html-pipeline-linkify_github/pull/4)
|
8
|
+
|
5
9
|
## 1.0.1 - 2015.10.15
|
6
10
|
|
7
11
|
- Linkify after markdown generated html. [#3](https://github.com/jollygoodcode/html-pipeline-linkify_github/pull/3/)
|
data/Gemfile
CHANGED
@@ -24,11 +24,12 @@ module HTML
|
|
24
24
|
|
25
25
|
def call
|
26
26
|
doc.search("a").each do |element|
|
27
|
+
next if element.blank? || element.comment?
|
27
28
|
next if element["href"].to_s.empty?
|
28
29
|
|
29
|
-
text = element.
|
30
|
+
text = element.inner_html
|
30
31
|
|
31
|
-
element.
|
32
|
+
element.inner_html = if is_a_pull_request_link? text
|
32
33
|
replace_pull_request_link(text)
|
33
34
|
elsif is_a_issue_link? text
|
34
35
|
replace_issue_link(text)
|
@@ -57,19 +58,19 @@ module HTML
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def replace_pull_request_link(text)
|
60
|
-
text.
|
61
|
+
text.gsub(PULL_REQUEST_REGEXP) do
|
61
62
|
pull_request_shorthand($1, $2, $3)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
def replace_issue_link(text)
|
66
|
-
text.
|
67
|
+
text.gsub(ISSUES_REGEXP) do
|
67
68
|
issue_shorthand($1, $2, $3)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
72
|
def replace_commit_link(text)
|
72
|
-
text.
|
73
|
+
text.gsub(COMMIT_REGEXP) do
|
73
74
|
commit_shorthand($1, $2, $3)
|
74
75
|
end
|
75
76
|
end
|
@@ -83,7 +84,7 @@ module HTML
|
|
83
84
|
end
|
84
85
|
|
85
86
|
def commit_shorthand(repo, owner, number)
|
86
|
-
"#{repo}/#{owner}
|
87
|
+
"#{repo}/#{owner}@<code>#{number[0..5]}</code>"
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|
@@ -10,6 +10,7 @@ class HTML::Pipeline::LinkifyGitHubIntegrationTest < Minitest::Test
|
|
10
10
|
HTML::Pipeline::LinkifyGitHubFilter
|
11
11
|
]
|
12
12
|
end
|
13
|
+
|
13
14
|
def test_works_with_markdown_filter
|
14
15
|
result = pipeline.call <<-MARKDOWN.strip_heredoc
|
15
16
|
https://github.com/rails/rails/pull/21862
|
@@ -17,7 +18,7 @@ class HTML::Pipeline::LinkifyGitHubIntegrationTest < Minitest::Test
|
|
17
18
|
https://github.com/rails/rails/commit/67597e1719ec6af7e22964603cc77aa5b085a864
|
18
19
|
MARKDOWN
|
19
20
|
|
20
|
-
assert_equal "<p><a href=\"https://github.com/rails/rails/pull/21862\">rails/rails#21862</a><br>\n<a href=\"https://github.com/rails/rails/issues/21843\">rails/rails#21843</a><br>\n<a href=\"https://github.com/rails/rails/commit/67597e1719ec6af7e22964603cc77aa5b085a864\">rails/rails
|
21
|
+
assert_equal "<p><a href=\"https://github.com/rails/rails/pull/21862\">rails/rails#21862</a><br>\n<a href=\"https://github.com/rails/rails/issues/21843\">rails/rails#21843</a><br>\n<a href=\"https://github.com/rails/rails/commit/67597e1719ec6af7e22964603cc77aa5b085a864\">rails/rails@<code>67597e</code></a></p>",
|
21
22
|
result[:output].to_html
|
22
23
|
end
|
23
24
|
|
@@ -29,4 +30,13 @@ class HTML::Pipeline::LinkifyGitHubIntegrationTest < Minitest::Test
|
|
29
30
|
assert_equal "<ul>\n<li><a href=\"https://github.com/rails/rails/pull/21862\">rails/rails#21862</a></li>\n</ul>",
|
30
31
|
result[:output].to_html
|
31
32
|
end
|
33
|
+
|
34
|
+
def test_preserve_tags_inside_link
|
35
|
+
result = pipeline.call <<-MARKDOWN.strip_heredoc
|
36
|
+
- [**rails/rails#21862**](https://github.com/rails/rails/pull/21862)
|
37
|
+
MARKDOWN
|
38
|
+
|
39
|
+
assert_equal "<ul>\n<li><a href=\"https://github.com/rails/rails/pull/21862\"><strong>rails/rails#21862</strong></a></li>\n</ul>",
|
40
|
+
result[:output].to_html
|
41
|
+
end
|
32
42
|
end
|
data/test/linkify_github_test.rb
CHANGED
@@ -46,7 +46,7 @@ class HTML::Pipeline::LinkifyGitHubTest < Minitest::Test
|
|
46
46
|
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
47
47
|
|
48
48
|
res = filter(doc)
|
49
|
-
assert_equal_html %Q(<a href="#{commit_url}">rails/rails
|
49
|
+
assert_equal_html %Q(<a href="#{commit_url}">rails/rails@<code>67597e</code></a>),
|
50
50
|
res.to_html
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline-linkify_github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanito Fatas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|