History

Fix python filter removing valid content

Fixes #320.

Thibaut committed 10 years ago

Commit 5eab92a1 parent 87080c21 file · +11 −3Browse files

Showing the changes to lib/docs/filters/python (1 of 1 file). Show all

Unified · Split

lib/docs/filters/python/clean_html.rb+11−3
@@ -2,7 +2,11 @@ module Docs · 1 unmodified line
22 class Python
33 class CleanHtmlFilter < Filter
44 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
610
711 # Clean inline code elements
812
@@ -30,8 +34,12 @@ module Docs · 21 unmodified lines
3034
3135 # Clean headings
3236
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
3543 end
3644
3745 css('h2', 'h3', 'h4').each do |node|