mirror of
https://github.com/iSharkFly-Docs/opensearch-docs-cn
synced 2025-03-09 14:38:01 +00:00
Improve logging of the link checker (#1252)
Signed-off-by: Miki <miki@amazon.com> Signed-off-by: Miki <miki@amazon.com>
This commit is contained in:
parent
fc03a5ea5d
commit
9da8dc23b6
@ -61,6 +61,7 @@ module Jekyll::LinkChecker
|
|||||||
@site = site
|
@site = site
|
||||||
@urls = {}
|
@urls = {}
|
||||||
@failures = []
|
@failures = []
|
||||||
|
@base_url_matcher = /^#{@site.config["url"]}#{@site.baseurl}(\/.*)$/.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
# Processes a Document or Page and adds the links to a collection
|
# Processes a Document or Page and adds the links to a collection
|
||||||
@ -74,9 +75,12 @@ module Jekyll::LinkChecker
|
|||||||
relative_path = page.path[0] == '/' ? Pathname.new(page.path).relative_path_from(Dir.getwd) : page.path
|
relative_path = page.path[0] == '/' ? Pathname.new(page.path).relative_path_from(Dir.getwd) : page.path
|
||||||
|
|
||||||
if href.start_with? '#'
|
if href.start_with? '#'
|
||||||
p relative_path if (page.content =~ /<[a-z0-9-]+[^>]+id="#{href[1..]}"/i).nil?
|
|
||||||
@failures << "##{href[1..]}, linked in ./#{relative_path}" if (page.content =~ /<[a-z0-9-]+[^>]+id="#{href[1..]}"/i).nil?
|
@failures << "##{href[1..]}, linked in ./#{relative_path}" if (page.content =~ /<[a-z0-9-]+[^>]+id="#{href[1..]}"/i).nil?
|
||||||
else
|
else
|
||||||
|
match = @base_url_matcher.match(href)
|
||||||
|
unless match.nil?
|
||||||
|
href = match[1]
|
||||||
|
end
|
||||||
@urls[href] = Set[] unless @urls.key?(href)
|
@urls[href] = Set[] unless @urls.key?(href)
|
||||||
@urls[href] << relative_path
|
@urls[href] << relative_path
|
||||||
end
|
end
|
||||||
@ -101,8 +105,6 @@ module Jekyll::LinkChecker
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@base_url_matcher = /^#{@site.config["url"]}#{@site.baseurl}(\/.*)$/.freeze
|
|
||||||
|
|
||||||
@urls.each do |url, pages|
|
@urls.each do |url, pages|
|
||||||
@failures << "#{url}, linked to in ./#{pages.to_a.join(", ./")}" unless self.check(url)
|
@failures << "#{url}, linked to in ./#{pages.to_a.join(", ./")}" unless self.check(url)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user