diff --git a/lib/docs/filters/eigen3/clean_html.rb b/lib/docs/filters/eigen3/clean_html.rb index 0542507e..3cbe6bb2 100644 --- a/lib/docs/filters/eigen3/clean_html.rb +++ b/lib/docs/filters/eigen3/clean_html.rb @@ -12,16 +12,6 @@ module Docs css('.top').remove css('.dynheader.closed').remove css('.permalink').remove - - css("div.fragment").each do |node| - node.name = 'pre' - node['data-language'] = 'cpp' - node_content = "" - node.css('div').each do |inner_node| - node_content += inner_node.text + "\n" - end - node.content = node_content - end doc end end diff --git a/lib/docs/scrapers/eigen3.rb b/lib/docs/scrapers/eigen3.rb index c7ed97a6..30722b2e 100644 --- a/lib/docs/scrapers/eigen3.rb +++ b/lib/docs/scrapers/eigen3.rb @@ -41,5 +41,29 @@ module Docs # TODO: replace cppreference # options[:replace_urls] = { 'http://en.cppreference.com/w/cpp/' => 'cpp/' } + def parse(response) # Hook here because Nokogori removes whitespace from code fragments + last_idx = 0 + # Process nested
s inside code fragment div. + while not (last_idx = response.body.index('
', last_idx)).nil? + # enter code fragment
+ level = 1 + while not (last_idx = response.body.index(/<\/?div/, last_idx+1)).nil? + # skip nested divs inside. + if response.body[last_idx..last_idx+3] == '' + response.body[last_idx..last_idx+5] = '' + end + end + response.body.gsub! /[\r\n\s]*
]*>.*<\/div>[\r\n\s]*/, "" + response.body.gsub! /
(.*?)<\/div>/m, "\\1" + response.body.gsub! '
', '
'
+      super
+    end
   end
 end