diff --git a/assets/stylesheets/pages/_c.scss b/assets/stylesheets/pages/_c.scss
index 2af1bf60..b9c4c25f 100644
--- a/assets/stylesheets/pages/_c.scss
+++ b/assets/stylesheets/pages/_c.scss
@@ -46,6 +46,8 @@
+ div { margin-left: .5em; }
}
+
+ > table { margin: 0; }
}
.t-dcl-rev-aux > td:empty { padding: 0; }
diff --git a/lib/docs/core/scrapers/file_scraper.rb b/lib/docs/core/scrapers/file_scraper.rb
index 58a252da..a8f29d62 100644
--- a/lib/docs/core/scrapers/file_scraper.rb
+++ b/lib/docs/core/scrapers/file_scraper.rb
@@ -39,7 +39,10 @@ module Docs
end
def read_file(path)
- File.read(path) rescue nil
+ File.read(path)
+ rescue
+ puts "Failed to open file: #{path}"
+ nil
end
end
end
diff --git a/lib/docs/filters/c/clean_html.rb b/lib/docs/filters/c/clean_html.rb
index 46ddd0b8..0665a941 100644
--- a/lib/docs/filters/c/clean_html.rb
+++ b/lib/docs/filters/c/clean_html.rb
@@ -4,12 +4,17 @@ module Docs
def call
css('h1').remove if root_page?
+ css('.t-dcl-rev-aux td[rowspan]').each do |node|
+ rowspan = node['rowspan'].to_i
+ node['rowspan'] = node.ancestors('tbody').css('tr').length if rowspan > 3
+ end
+
css('#siteSub', '#contentSub', '.printfooter', '.t-navbar', '.editsection', '#toc',
'.t-dsc-sep', '.t-dcl-sep', '#catlinks', '.ambox-notice', '.mw-cite-backlink',
'.t-sdsc-sep:first-child:last-child', '.t-example-live-link',
'.t-dcl-rev-num > .t-dcl-rev-aux ~ tr:not(.t-dcl-rev-aux) > td:nth-child(2)').remove
- css('#bodyContent', '.mw-content-ltr', 'span[style]', 'div[class^="t-ref"]',
+ css('#bodyContent', '.mw-content-ltr', 'span[style]', 'div[class^="t-ref"]', '.t-image',
'th > div', 'td > div', '.t-dsc-see', '.mainpagediv', 'code > b', 'tbody').each do |node|
node.before(node.children).remove
end
@@ -78,7 +83,7 @@ module Docs
end
node.inner_html = node.inner_html.strip
node << '.' if node.content =~ /[a-zA-Z0-9\)]\z/
- node.remove if node.content.blank?
+ node.remove if node.content.blank? && !node.at_css('img')
end
css('pre').each do |node|
@@ -100,6 +105,10 @@ module Docs
node.content = node.content
end
+ css('img').each do |node|
+ node['src'] = node['src'].sub! %r{http://en.cppreference.com/common/([^"']+?)\.svg}, 'http://upload.cppreference.com/mwiki/\1.svg'
+ end
+
doc
end
end
diff --git a/lib/docs/filters/cpp/fix_urls.rb b/lib/docs/filters/cpp/fix_urls.rb
index d9936f6d..8e8d67c6 100644
--- a/lib/docs/filters/cpp/fix_urls.rb
+++ b/lib/docs/filters/cpp/fix_urls.rb
@@ -4,7 +4,6 @@ module Docs
def call
html.gsub! File.join(Cpp.base_url, Cpp.root_path), Cpp.base_url[0..-2]
html.gsub! %r{#{Cpp.base_url}([^"']+?)\.html}, "#{Cpp.base_url}\\1"
- html.gsub! %r{http://en.cppreference.com/common/([^"']+?)\.svg}, 'http://upload.cppreference.com/mwiki/\1.svg'
html
end
end
diff --git a/lib/docs/scrapers/c.rb b/lib/docs/scrapers/c.rb
index da651fa9..27897792 100644
--- a/lib/docs/scrapers/c.rb
+++ b/lib/docs/scrapers/c.rb
@@ -9,6 +9,7 @@ module Docs
html_filters.push 'c/entries', 'c/clean_html', 'title'
text_filters.push 'c/fix_urls'
+ options[:decode_and_clean_paths] = true
options[:container] = '#content'
options[:title] = false
options[:root_title] = 'C Programming Language'
@@ -25,5 +26,11 @@ module Docs
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML
+
+ private
+
+ def file_path_for(*)
+ URI.unescape(super)
+ end
end
end
diff --git a/lib/docs/scrapers/cpp.rb b/lib/docs/scrapers/cpp.rb
index 4b980646..5b801017 100644
--- a/lib/docs/scrapers/cpp.rb
+++ b/lib/docs/scrapers/cpp.rb
@@ -11,6 +11,7 @@ module Docs
html_filters.push 'cpp/entries', 'c/clean_html', 'title'
text_filters.push 'cpp/fix_urls'
+ options[:decode_and_clean_paths] = true
options[:container] = '#content'
options[:title] = false
options[:root_title] = 'C++ Programming Language'
@@ -33,5 +34,11 @@ module Docs
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML
+
+ private
+
+ def file_path_for(*)
+ URI.unescape(super)
+ end
end
end