| @@ -2,6 +2,12 @@ module Docs · 1 unmodified line |
| 2 | class D3 | 2 | class D3 |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| | 5 | # Remove links inside <h2> and add "id" attributes |
| | 6 | css('h2 > a').each do |node| |
| | 7 | node.parent['id'] = node['name'].sub('wiki-', '') if node['name'] |
| | 8 | node.before(node.children).remove |
| | 9 | end |
| | 10 | |
| 5 | css('#gollum-footer', '.markdown-body > blockquote:first-child', '.anchor').remove | 11 | css('#gollum-footer', '.markdown-body > blockquote:first-child', '.anchor').remove |
| 6 | | 12 | |
| 7 | # Replace #head with <h1> | 13 | # Replace #head with <h1> |
| @@ -15,21 +21,6 @@ module Docs · 7 unmodified lines |
| 15 | node.before(node.at_css('.markdown-body').children).remove | 21 | node.before(node.at_css('.markdown-body').children).remove |
| 16 | end | 22 | end |
| 17 | | 23 | |
| 18 | # Remove links inside <h2> | | |
| 19 | css('h2 > a').each do |node| | | |
| 20 | node.before(node.children).remove | | |
| 21 | end | | |
| 22 | | | |
| 23 | # Make headings for function definitions and add "id" attributes | | |
| 24 | css('p > a:first-child').each do |node| | | |
| 25 | next unless node['name'] || node.content == '#' | | |
| 26 | parent = node.parent | | |
| 27 | parent.name = 'h6' | | |
| 28 | parent['id'] = (node['name'] || node['href'].sub(/\A.+#/, '')).sub('wiki-', '') | | |
| 29 | parent.css('a[name]').remove | | |
| 30 | node.remove | | |
| 31 | end | | |
| 32 | | | |
| 33 | # Make headings for function definitions and add "id" attributes | 24 | # Make headings for function definitions and add "id" attributes |
| 34 | css('p > a:first-child').each do |node| | 25 | css('p > a:first-child').each do |node| |
| 35 | next unless node['name'] || node.content == '#' | 26 | next unless node['name'] || node.content == '#' |