@@ -2,50 +2,38 @@ module Docs
22 class Jekyll
33 class CleanHtmlFilter < Filter
44 def call
5- css ( '.improve, .section-nav' ) . each ( &:remove )
5+ @doc = at_css ( 'article' )
6+
7+ at_css ( 'h1' ) . content = 'Jekyll' if root_page?
8+
9+ css ( '.improve, .section-nav' ) . remove
610
711 css ( 'div.highlighter-rouge' ) . each do |node |
812 pre = node . at_css ( 'pre' )
913
10- # copy over the highlighting metadata
11- match = /language-(\w +)/ . match ( node [ 'class' ] )
14+ lang = node [ 'class' ] [ /language-(\w +)/ , 1 ]
1215 # HACK: Prism shell highlighting highlights `|`,
1316 # which makes the tree on this page look terrible
14- if match && !( slug == /structure/ && match [ 1 ] == 'sh' )
15- lang = match [ 1 ]
16- if lang == 'sh'
17- lang = 'bash'
18- elsif lang == 'liquid'
19- lang = 'django' # Close enough.
20- end
21- pre [ 'class' ] = nil
17+ unless slug . include? ( 'structure' ) && lang == 'sh'
18+ lang = 'bash' if lang == 'sh'
2219 pre [ 'data-language' ] = lang
2320 end
2421
25- # Remove the server-rendered syntax highlighting
26- code = pre . at_css ( 'code' )
27- code . content = code . text
28-
29- # Remove the div.highlighter-rouge and div.highlight wrapping the <pre>
30- node . add_next_sibling pre
31- node . remove
22+ pre . remove_attribute ( 'class' )
23+ pre . content = pre . content
24+ node . replace ( pre )
3225 end
3326
34- css ( 'code' ) . each do |node |
35- node [ 'class' ] = ''
36- end
27+ css ( 'code' ) . remove_attr ( 'class' )
3728
3829 css ( '.note' ) . each do |node |
39- node_type = /note ?( \w +)?/ . match ( node [ 'class' ] ) [ 1 ] || 'tip '
30+ node . name = 'blockquote '
4031
4132 # <div class="note">...<br>...</div> -> <div class="note">...</div>
4233 ( node > 'br' ) . each ( &:remove )
4334 # <div class="note">...<p>...<br><br>...</p>...</div> ->
4435 # <div class="note">...<p>...<br>...</p>...</div>
4536 node . css ( 'br + br' ) . each ( &:remove )
46-
47- node [ 'class' ] = "note note-#{ node_type } "
48- node [ 'data-type' ] = node_type
4937 end
5038
5139 doc
0 commit comments