devcenter-parser 2.2.5 → 2.2.6
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 +4 -4
- data/lib/devcenter-parser.rb +5 -1
- data/lib/devcenter-parser/version.rb +1 -1
- data/test/devcenter-parser_test.rb +9 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 177652c3cda82510b487a9319f2a87c1aeca16b697e56de5cc8690f92d141897
|
4
|
+
data.tar.gz: ee6bf49ffb53ad0094092c67179607fef3baecb53c49172d1f63c57a09770670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ce23a79c6e9acf16eee9e969b8ded4c58f4e489ca52415b87227eb8c97ac8b93756fbcfa5a5ab49c0f8187da1efab76feb6719c7d500e7567cdeae2dc50375
|
7
|
+
data.tar.gz: be81f08407afab73eac94c402b0b59223cc7e9439696131651d9c8aaaead10a7a2228ff9d6ad27943cbf44ed6551d54d5628182e3127f0a436598d9452fd6b17
|
data/lib/devcenter-parser.rb
CHANGED
@@ -94,7 +94,11 @@ module DevcenterParser
|
|
94
94
|
|
95
95
|
def self.convert_to_article_links_all_relative_links_with_missing_initial_slashes(doc)
|
96
96
|
doc.css('a').each do |node|
|
97
|
-
|
97
|
+
next if node['href'].nil? || node['href'] =~ /\Ahttp|\A\/|\Amailto\:|\A#/
|
98
|
+
|
99
|
+
if node['href'].start_with? 'categories/'
|
100
|
+
node['href'] = "/#{node['href']}"
|
101
|
+
else
|
98
102
|
node['href'] = "/articles/#{node['href']}".gsub('/articles/articles/', '/articles/')
|
99
103
|
end
|
100
104
|
end
|
@@ -336,13 +336,21 @@ HTML
|
|
336
336
|
end
|
337
337
|
|
338
338
|
it 'converts relative links with missing initial slashes to article links' do
|
339
|
-
['foo', 'foo/bar', 'foo#bar', '123'].each do |href|
|
339
|
+
['foo', 'foo/bar', 'foo#bar', '123', 'categories'].each do |href|
|
340
340
|
md = "[link](#{href})"
|
341
341
|
html = "<p><a href=\"/articles/#{href}\">link</a></p>"
|
342
342
|
assert_parsing_result md, html
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
346
|
+
it 'ignores links with missing initial slashes IFF they start with `categories/`' do
|
347
|
+
['categories/foo', 'categories/foo/bar', 'categories/foo#bar', 'categories/123'].each do |href|
|
348
|
+
md = "[link](#{href})"
|
349
|
+
html = "<p><a href=\"/#{href}\">link</a></p>"
|
350
|
+
assert_parsing_result md, html
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
346
354
|
it 'converts "articles/foo relative links with missing initial slashes to article links' do
|
347
355
|
md = '[link](articles/foo)'
|
348
356
|
html = '<p><a href="/articles/foo">link</a></p>'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devcenter-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heroku
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.7.
|
122
|
+
rubygems_version: 2.7.6
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Parser for Heroku Dev Center's content
|