Class: Docs::Mdn::CleanHtmlFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/docs/filters/mdn/clean_html.rb

Constant Summary collapse

REMOVE_NODES =
[
'#Summary',          # "Summary" heading
'.htab',             # "Browser compatibility" tabs
'.breadcrumbs',      # (e.g. CSS/animation)
'.Quick_links',      # (e.g. CSS/animation)
'.todo',
'.draftHeader']

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#callObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/docs/filters/mdn/clean_html.rb', line 12

def call
  css(*REMOVE_NODES).remove

  css('td.header').each do |node|
    node.name = 'th'
  end

  css('nobr').each do |node|
    node.before(node.children).remove
  end

  css('h2[style]', 'pre[style]').remove_attr('style')

  doc
end