html-pipeline-linkify_github 1.0.1 → 1.0.2

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: b7d544ff42bdaed0ad76d2b225dc17eda21a8ce9
4
- data.tar.gz: 7ef282549e3dbcdaa6df7fec6b8aa9dccf0d0ba6
3
+ metadata.gz: 6ffe55eb51973c6e4aeb83b1313e2b59ad71940a
4
+ data.tar.gz: 8a8edc700201c6ea6f21b9ee819a74d53c239e74
5
5
  SHA512:
6
- metadata.gz: 9d8d7f78298b42446740ec56ffafbad473c0f7c361a370d9c4b571421f3c278da68f50094df93d004003a855f03aad00f8e0c821c9c1809cd50b135e2a835e76
7
- data.tar.gz: 90c5eac937732170879a89d1c59d9cedda236375251e4e867344a21afe9bca021a70d9ae6e954cefdc4761b21aa04daab33fcc76abf5e2dfffa4e9a9021ec780
6
+ metadata.gz: 5fc7fd9cf12c8a39ecf1a51024ae2264b15a6938e05e568b6f2e01e5b7b042610db7a1caab3328d641fcaa6e82f29bbffde1c38cde14c98eaf61a4f45f533b7a
7
+ data.tar.gz: 44938bffae471376d7917591f75b3d2737eadd09f16d7941a95b0f7c8ecf2c6c2cf0a20292420dd3ae8b448817eae669fb27558fe402db12d0ee53fd06824783
@@ -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
@@ -7,6 +7,7 @@ group :development do
7
7
  gem "rake"
8
8
  gem "bundler"
9
9
  gem "pry"
10
+ gem "pry-nav"
10
11
  gem "github-markdown"
11
12
  end
12
13
 
@@ -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.content
30
+ text = element.inner_html
30
31
 
31
- element.content = if is_a_pull_request_link? text
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.match(PULL_REQUEST_REGEXP) do
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.match(ISSUES_REGEXP) do
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.match(COMMIT_REGEXP) do
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}@`#{number[0..5]}`"
87
+ "#{repo}/#{owner}@<code>#{number[0..5]}</code>"
87
88
  end
88
89
  end
89
90
  end
@@ -1,7 +1,7 @@
1
1
  module HTML
2
2
  class Pipeline
3
3
  module LinkifyGitHub
4
- VERSION = "1.0.1".freeze
4
+ VERSION = "1.0.2".freeze
5
5
  end
6
6
  end
7
7
  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@`67597e`</a></p>",
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
@@ -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@`67597e`</a>),
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.1
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-14 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-pipeline