|
|
|
@ -2,6 +2,12 @@ module Docs
|
|
|
|
|
class D3
|
|
|
|
|
class CleanHtmlFilter < Filter
|
|
|
|
|
def call
|
|
|
|
|
# Remove links inside <h2> and add "id" attributes
|
|
|
|
|
css('h2 > a').each do |node|
|
|
|
|
|
node.parent['id'] = node['name'].sub('wiki-', '') if node['name']
|
|
|
|
|
node.before(node.children).remove
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
css('#gollum-footer', '.markdown-body > blockquote:first-child', '.anchor').remove
|
|
|
|
|
|
|
|
|
|
# Replace #head with <h1>
|
|
|
|
@ -15,21 +21,6 @@ module Docs
|
|
|
|
|
node.before(node.at_css('.markdown-body').children).remove
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Remove links inside <h2>
|
|
|
|
|
css('h2 > a').each do |node|
|
|
|
|
|
node.before(node.children).remove
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Make headings for function definitions and add "id" attributes
|
|
|
|
|
css('p > a:first-child').each do |node|
|
|
|
|
|
next unless node['name'] || node.content == '#'
|
|
|
|
|
parent = node.parent
|
|
|
|
|
parent.name = 'h6'
|
|
|
|
|
parent['id'] = (node['name'] || node['href'].sub(/\A.+#/, '')).sub('wiki-', '')
|
|
|
|
|
parent.css('a[name]').remove
|
|
|
|
|
node.remove
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Make headings for function definitions and add "id" attributes
|
|
|
|
|
css('p > a:first-child').each do |node|
|
|
|
|
|
next unless node['name'] || node.content == '#'
|
|
|
|
|