Jelajahi Sumber

Download images by default

Rel: #633
Thibaut Courouble 8 tahun lalu
induk
melakukan
f7580a8b52

+ 1 - 0
lib/docs/core/scraper.rb

@@ -42,6 +42,7 @@ module Docs
     self.text_filters = FilterStack.new
 
     html_filters.push 'apply_base_url', 'container', 'clean_html', 'normalize_urls', 'internal_urls', 'normalize_paths'
+    text_filters.push 'images' # ensure the images filter runs after all html filters
     text_filters.push 'inner_html', 'clean_text', 'attribution'
 
     def initialize

+ 2 - 0
lib/docs/filters/core/images.rb

@@ -10,6 +10,8 @@ module Docs
     end
 
     def call
+      return doc if context[:download_images] == false
+
       @@cache ||= {}
 
       doc.css('img[src]').each do |node|

+ 1 - 1
lib/docs/scrapers/mdn/mdn.rb

@@ -6,7 +6,7 @@ module Docs
     params[:raw] = 1
     params[:macros] = 1
 
-    html_filters.push 'mdn/clean_html', 'images'
+    html_filters.push 'mdn/clean_html'
     text_filters.insert_before 'attribution', 'mdn/contribute_link'
 
     options[:trailing_slash] = false