FIX: HtmlToMarkdown didn't keep text from within <center> tag

It should ignore the `<center>` tag, but keep the text from within the element.
This commit is contained in:
Gerhard Schlager 2024-06-09 13:32:52 +02:00 committed by Gerhard Schlager
parent b01905c724
commit 3c9d61d302
2 changed files with 5 additions and 1 deletions

@ -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)

@ -413,6 +413,10 @@ RSpec.describe HtmlToMarkdown do
expect(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>" do
expect(html_to_markdown("<script>var foo = 'bar'</script>")).to eq("")
end