From 6cff40e729360f3f883556bb438dbb54c09f956c Mon Sep 17 00:00:00 2001 From: Gergely Gombos Date: Sun, 1 Dec 2024 20:21:09 +0100 Subject: [PATCH] more styling removal --- .../filters/react/clean_html_react_dev.rb | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/docs/filters/react/clean_html_react_dev.rb b/lib/docs/filters/react/clean_html_react_dev.rb index 07c47726..fb77fa14 100644 --- a/lib/docs/filters/react/clean_html_react_dev.rb +++ b/lib/docs/filters/react/clean_html_react_dev.rb @@ -9,13 +9,27 @@ module Docs node.previous.remove end - # Remove prev-next links - css('div.grid > a').each do |node| + remove_selectors = [ + 'div.grid > a', # prev-next links + 'button', # "show more" etc. buttons + 'div.order-last', # code iframe containers + 'a[title="Open in CodeSandbox"]', # codesandbox links + ] + css(*remove_selectors).each do |node| node.remove end - # Remove styling divs - css('div[class*="ps-0"]', 'div[class*="mx-"]', 'div[class*="px-"]', 'div[class=""]', 'div.cm-line').each do |node| + # Remove recipe blocks - TODO transform to outgoing link to docs + css('h4[id^="examples-"]').each do |node| + node.parent.parent.parent.remove + end + + # Remove styling divs while lifting children + styling_prefixes = [ + 'ps-', 'mx-', 'my-', 'px-', 'py-', 'mb-', 'sp-', 'rounded-' + ] + selectors = styling_prefixes.map { |prefix| "div[class*=\"#{prefix}\"]" } + css(*selectors, 'div[class=""]', 'div.cm-line').each do |node| node.before(node.children).remove end