diff --git a/lib/docs/core/scrapers/file_scraper.rb b/lib/docs/core/scrapers/file_scraper.rb index b71da75f..4671901b 100644 --- a/lib/docs/core/scrapers/file_scraper.rb +++ b/lib/docs/core/scrapers/file_scraper.rb @@ -13,6 +13,8 @@ module Docs self.base_url = 'http://localhost/' + html_filters.push 'clean_local_urls' + private def request_one(url) diff --git a/lib/docs/filters/core/clean_local_urls.rb b/lib/docs/filters/core/clean_local_urls.rb new file mode 100644 index 00000000..15954a6b --- /dev/null +++ b/lib/docs/filters/core/clean_local_urls.rb @@ -0,0 +1,16 @@ +module Docs + class CleanLocalUrlsFilter < Filter + def call + if base_url.host == 'localhost' + css('img[src^="http://localhost"]', 'iframe[src^="http://localhost"]').remove + + css('a[href^="http://localhost"]').each do |node| + node.name = 'span' + node.remove_attribute 'href' + end + end + + doc + end + end +end