@@ -2,35 +2,29 @@ module Docs
22 class Pygame
33 class CleanHtmlFilter < Filter
44 def call
5-
65 @doc = at_css '.body'
76
87 if root_page?
98 # remove unneeded stuff
109 at_css ( '.modindex-jumpbox' ) . remove
11- css ( '[role="navigation"],.pcap, .cap, .footer' ) . each do |node |
12- node . remove
13- end
10+ css ( '[role="navigation"],.pcap, .cap, .footer' ) . remove
1411 # table -> list
1512 list = at_css ( 'table' )
1613 list . replace ( list . children )
1714 list . name = 'ul'
1815 css ( 'tr' ) . each do |row |
1916 row . name = 'li'
20- row [ 'class' ] = ''
17+ row . remove_attribute ( 'class' )
2118 end
19+ at_css ( 'h1' ) . content = 'Pygame'
2220 return doc
2321 end
2422
2523 # remove unwanted stuff
2624 # .headerlink => ¶ after links
2725 # .toc => table of content
2826 # .tooltip-content => tooltips after links to functions
29- if toremove = css ( 'table.toc.docutils, .headerlink, .tooltip-content' )
30- toremove . each do |node |
31- node . remove
32- end
33- end
27+ css ( 'table.toc.docutils, .headerlink, .tooltip-content' ) . remove
3428
3529 # Remove wrapper .section
3630 section = at_css ( '.section' )
@@ -43,7 +37,7 @@ def call
4337 pre = node . at_css ( 'pre' )
4438 node . replace ( pre )
4539 # gets rid of the already existing syntax highlighting
46- pre . inner_html = pre . inner_text
40+ pre . content = pre . content
4741 pre [ 'class' ] = 'language-python'
4842 pre [ 'data-language' ] = "python"
4943 end
@@ -97,6 +91,10 @@ def call
9791 end
9892 end
9993
94+ css ( '> dl' , '> dl > dd' , 'h1 code' ) . each do |node |
95+ node . before ( node . children ) . remove
96+ end
97+
10098 doc
10199 end
102100 end
0 commit comments