(PDOC-36) fix hack for README urls

Discovered that this hack was finding broken links and then replacing all instances of the link text in the README. This led to a lot of non-links being affected. This patch works harder to match only actual links and works as far as I can tell.
This commit is contained in:
Eric Putnam 2018-04-23 15:16:02 +01:00
parent 37cfe49f95
commit 5d2c4411ca
No known key found for this signature in database
GPG Key ID: 3FB595AA224A7751
2 changed files with 6 additions and 1 deletions

View File

@ -24,7 +24,7 @@ module PuppetStrings::Yard::Util
# @return [String] HTML document with links converted
def self.github_to_yard_links(data)
data.scan(/href\=\"\#(.+)\"/).each do |bad_link|
data.gsub!(bad_link.first, "label-#{bad_link.first.capitalize.gsub('-', '+')}")
data.gsub!("=\"##{bad_link.first}\"", "=\"#label-#{bad_link.first.capitalize.gsub('-', '+')}\"")
end
data
end

View File

@ -39,5 +39,10 @@ STR
str = '<a href="www.github.com/blah/document.html#module-description">'
expect(subject.github_to_yard_links(str)).to eq(str)
end
it 'leaves plain text alone' do
str = '<a href="#module-description"> module-description'
expect(subject.github_to_yard_links(str)).to eq('<a href="#label-Module+description"> module-description')
end
end
end