From 63dd3dce7001b30ededaf46c9a84eb2bc9f126e7 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sun, 17 Nov 2024 11:26:12 +0100 Subject: [PATCH] cordova: do not clean   Do not use core/clean_html filter. --- lib/docs/filters/cordova/clean_html_core.rb | 11 +++++++++++ lib/docs/filters/core/clean_html.rb | 1 - lib/docs/scrapers/cordova.rb | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 lib/docs/filters/cordova/clean_html_core.rb diff --git a/lib/docs/filters/cordova/clean_html_core.rb b/lib/docs/filters/cordova/clean_html_core.rb new file mode 100644 index 00000000..c8625486 --- /dev/null +++ b/lib/docs/filters/cordova/clean_html_core.rb @@ -0,0 +1,11 @@ +module Docs + class Cordova + class CleanHtmlCoreFilter < Filter + def call + css('script', 'style', 'link').remove + xpath('descendant::comment()').remove + doc + end + end + end +end diff --git a/lib/docs/filters/core/clean_html.rb b/lib/docs/filters/core/clean_html.rb index c8a7cfc1..f17333c0 100644 --- a/lib/docs/filters/core/clean_html.rb +++ b/lib/docs/filters/core/clean_html.rb @@ -8,7 +8,6 @@ module Docs xpath('./text()', './/text()[not(ancestor::pre) and not(ancestor::code) and not(ancestor::div[contains(concat(" ", normalize-space(@class), " "), " prism ")])]').each do |node| content = node.content next unless content.valid_encoding? - next if context[:clean_html_maintain_nbsp] && !content.index(" ").nil? content.gsub! %r{[[:space:]]+}, ' ' node.content = content end diff --git a/lib/docs/scrapers/cordova.rb b/lib/docs/scrapers/cordova.rb index 0ef04571..5cf0bf90 100644 --- a/lib/docs/scrapers/cordova.rb +++ b/lib/docs/scrapers/cordova.rb @@ -8,10 +8,10 @@ module Docs code: 'https://github.com/apache/cordova' } + html_filters.replace 'clean_html', 'cordova/clean_html_core' html_filters.push 'cordova/entries', 'cordova/clean_html' options[:container] = '.docs' - options[:clean_html_maintain_nbsp] = true options[:skip] = %w(index.html) options[:fix_urls] = ->(url) do