A platform for community discussion. Free, open, simple.
FIX: `HtmlToMarkdown` didn't keep text from within `<center>` tag
Gerhard Schlager3c9d61d30217
diff --git a/lib/html_to_markdown.rb b/lib/html_to_markdown.rbindex 1dbcf2b3b4f..d5c5f651659 100644--- a/lib/html_to_markdown.rb+++ b/lib/html_to_markdown.rb@@ -220,7 +220,7 @@ class HtmlToMarkdown"\n\n#{traverse(node)}\n\n"end- TRAVERSABLES ||= %w[aside font span thead tbody tfoot u]+ TRAVERSABLES ||= %w[aside font span thead tbody tfoot u center]TRAVERSABLES.each { |tag| define_method("visit_#{tag}") { |node| traverse(node) } }def visit_tt(node)diff --git a/spec/lib/html_to_markdown_spec.rb b/spec/lib/html_to_markdown_spec.rbindex a26f8f2313a..9731767f455 100644--- a/spec/lib/html_to_markdown_spec.rb+++ b/spec/lib/html_to_markdown_spec.rb@@ -413,6 +413,10 @@ RSpec.describe HtmlToMarkdown doexpect(html_to_markdown("<u>Underline</u>")).to eq("Underline")end+ it "swallows <center>" do+ expect(html_to_markdown("<center>Centered</center>")).to eq("Centered")+ end+it "removes <script>" doexpect(html_to_markdown("<script>var foo = 'bar'</script>")).to eq("")end