Fixes #320.
Unified · Split
| @@ -2,7 +2,11 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Python |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − @doc = at_css '.body > .section' | |
| 5 | + @doc = at_css '.body' | |
| 6 | + | |
| 7 | + css('> .section').each do |node| | |
| 8 | + node.before(node.children).remove | |
| 9 | + end | |
| 6 | 10 | |
| 7 | 11 | # Clean inline code elements |
| 8 | 12 | |
| @@ -30,8 +34,12 @@ module Docs · 21 unmodified lines | ||
| 30 | 34 | |
| 31 | 35 | # Clean headings |
| 32 | 36 | |
| 33 | − at_css('h1').tap do |node| | |
| 34 | − node.content = node.content.sub!(/\A[\d\.]+/) { |str| @levelRegexp = /\A#{str}/; '' } | |
| 37 | + css('h1').each do |node| | |
| 38 | + node.content = node.content.sub!(/\A[\d\.]+/) do |str| | |
| 39 | + rgx = /\A#{str}/ | |
| 40 | + @levelRegexp = @levelRegexp ? Regexp.union(@levelRegexp, rgx) : rgx | |
| 41 | + '' | |
| 42 | + end | |
| 35 | 43 | end |
| 36 | 44 | |
| 37 | 45 | css('h2', 'h3', 'h4').each do |node| |