|
|
@@ -0,0 +1,37 @@
|
|
|
+module Docs
|
|
|
+ class Electron
|
|
|
+ class CleanHtmlFilter < Filter
|
|
|
+ def call
|
|
|
+ css('.header-link', 'hr + .text-center', 'hr').remove
|
|
|
+
|
|
|
+ css('.grid', '.row', '.col-ms-12').each do |node|
|
|
|
+ node.before(node.children).remove
|
|
|
+ end
|
|
|
+
|
|
|
+ css('h2 > a').each do |node|
|
|
|
+ node.before(node.children).remove
|
|
|
+ end if root_page?
|
|
|
+
|
|
|
+ at_css('h2').name = 'h1' unless at_css('h1')
|
|
|
+
|
|
|
+ css('h3', 'h4', 'h5').each do |node|
|
|
|
+ node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code')
|
|
|
+ end if !at_css('h2') && at_css('h4')
|
|
|
+
|
|
|
+ css('div.highlighter-rouge').each do |node|
|
|
|
+ node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
|
|
|
+ node.content = node.content.strip
|
|
|
+ node.name = 'pre'
|
|
|
+ end
|
|
|
+
|
|
|
+ css('.highlighter-rouge').remove_attr('class')
|
|
|
+
|
|
|
+ css('pre').each do |node|
|
|
|
+ node.content = node.content
|
|
|
+ end
|
|
|
+
|
|
|
+ doc
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|