Rewrite links by generating scraper :replace_paths from entries filter

pull/1547/head
Cimbali 4 years ago
parent 42731d6407
commit 005db388ce

@ -4,14 +4,17 @@ module Docs
PKG_INDEX_ENTRIES = Hash.new []
def initialize(*)
super
def call
if slug_parts[-1] == '00Index'
dir = File.dirname(result[:subpath])
css('tr a').each do |link|
PKG_INDEX_ENTRIES[link['href']] += [link.text]
next if link['href'] == link.text
context[:replace_paths][File.join(dir, "#{link.text}.html")] = File.join(dir, "#{link['href']}.html")
end
end
super
end
def slug_parts

@ -29,14 +29,12 @@ module Docs
/\.pdf$/
]
## We want to fix links like so but only if the targets dont exist,
## as these target packages or keywords that do not have their own file,
## but exist on another page, and we properly record it.
#
#options[:fix_urls] = ->(url) do
# url.sub!(%r'/library/([^/]+)/doc/index.html$') { |m| "/r-#{$1.parameterize.downcase}/" }
# url.sub!(%r'/library/([^/]+)/html/([^/]+).html$') { |m| "/library/#{$1.parameterize.downcase}/html/#{$2.parameterize.downcase}" }
#end
options[:replace_paths] = {
## We want to fix links like so but only if the targets dont exist:
# 'library/MASS/html/cov.mve.html' => 'library/MASS/html/cov.rob.html'
## Paths for target packages or keywords that do not have their own file
## are generated in the entries filter from 00Index.html files
}
options[:skip] = %w(
doc/html/packages-head-utf8.html

Loading…
Cancel
Save