react_bootstrap: clean html

This commit is contained in:
Simon Legner 2021-02-26 08:24:59 +01:00
parent 306b264d76
commit 8ceba764dd

View file

@ -2,12 +2,14 @@ module Docs
class ReactBootstrap
class CleanHtmlFilter < Filter
def call
@doc = doc.at_css('main')
css('.flex-column.d-flex').remove
css('header').remove
css('.bs-example').remove
css('.position-relative pre').each do |node|
# node.content = node.content
node.content = node.children.map(&:content).join("\n")
node.remove_attribute('style')
node['data-language'] = 'jsx'
node.parent.replace(node)
@ -16,6 +18,10 @@ module Docs
css('div, main, pre, h1, h2, h3, h4, h5, h6, a, p').each do |node|
node.delete 'class'
end
css('h1, h2, h3, h4, h5, h6').each do |node|
node.css('a').remove
node.content = node.content
end
css('#___gatsby, #gatsby-focus-wrapper').each do |node|
node.delete 'id'