Fixes #320.
Showing the changes to lib/docs/filters/python (1 of 1 file). Show all
Unified · Split
| @@ -2,7 +2,11 @@ module Docs · 1 unmodified line | |||
| 2 | class Python | 2 | class Python |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 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 | # Clean inline code elements | 11 | # Clean inline code elements |
| 8 | 12 | ||
| @@ -30,8 +34,12 @@ module Docs · 21 unmodified lines | |||
| 30 | 34 | ||
| 31 | # Clean headings | 35 | # Clean headings |
| 32 | 36 | ||
| 33 | at_css('h1').tap do |node| | 37 | css('h1').each do |node| |
| 34 | node.content = node.content.sub!(/\A[\d\.]+/) { |str| @levelRegexp = /\A#{str}/; '' } | 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 | end | 43 | end |
| 36 | 44 | ||
| 37 | css('h2', 'h3', 'h4').each do |node| | 45 | css('h2', 'h3', 'h4').each do |node| |