[devdocsgjs/main: 18/69] sanctuary: simplify filter
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 18/69] sanctuary: simplify filter
- Date: Mon, 12 Sep 2022 18:46:54 +0000 (UTC)
commit 05362985016739c73ab4a639e6189884d94e028c
Author: Simon Legner <Simon Legner gmail com>
Date: Sat Aug 27 19:16:20 2022 +0200
sanctuary: simplify filter
lib/docs/filters/sanctuary/clean_html.rb | 26 +-------------------------
lib/docs/scrapers/sanctuary.rb | 8 ++++++++
2 files changed, 9 insertions(+), 25 deletions(-)
---
diff --git a/lib/docs/filters/sanctuary/clean_html.rb b/lib/docs/filters/sanctuary/clean_html.rb
index c76ea1c0..c3b00728 100644
--- a/lib/docs/filters/sanctuary/clean_html.rb
+++ b/lib/docs/filters/sanctuary/clean_html.rb
@@ -1,11 +1,3 @@
-def repeat(n, s)
- Array.new(n, s).join("")
-end
-
-def _(n)
- repeat(n, " ")
-end
-
module Docs
class Sanctuary
@@ -44,23 +36,7 @@ module Docs
node
.css("input")
.map { |node| "> " + node.attributes["value"].value }
- .zip(node.css(".output").map { |node|
- if node.content.start_with?("! Invalid value")
- # XXX: Reinstate newlines and consecutive spaces.
- content = node.content.dup()
- content[ 15] = "\n\n"
- content[ 68] = "\n" + _("add :: FiniteNumber -> ".size)
- content[104] = "\n" + _("add :: FiniteNumber -> ".size + ("FiniteNumber".size - 1) / 2)
- content[134] = "\n\n"
- content[138] = _(2)
- content[155] = "\n\n"
- content[215] = "\n\n"
- content[337] = "\n"
- content
- else
- node.content
- end
- })
+ .zip(node.css(".output").map { |node| node.content })
.map { |pair| pair.join("\n") }
.join("\n\n"),
{"data-language" => "javascript"}
diff --git a/lib/docs/scrapers/sanctuary.rb b/lib/docs/scrapers/sanctuary.rb
index 1f2a41dc..b569868d 100644
--- a/lib/docs/scrapers/sanctuary.rb
+++ b/lib/docs/scrapers/sanctuary.rb
@@ -20,6 +20,14 @@ module Docs
def get_latest_version(opts)
get_npm_version("sanctuary", opts)
end
+
+ private
+
+ def parse(response) # Hook here because Nokogori removes whitespace from textareas
+ response.body.gsub! %r{<div class="output"[^>]*>([\W\w]+?)</div>}, '<pre class="output">\1</pre>'
+ super
+ end
+
end
end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]