From b01905c7244a8552247d562ce36c23cc7a8b6c38 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Sun, 9 Jun 2024 13:26:39 +0200 Subject: [PATCH] FIX: `HtmlToMarkdown` didn't support `tfoot` in tables --- lib/html_to_markdown.rb | 2 +- spec/lib/html_to_markdown_spec.rb | 53 ++++++++++++++++++------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/lib/html_to_markdown.rb b/lib/html_to_markdown.rb index eff00c66341..1dbcf2b3b4f 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 tfooter u] + TRAVERSABLES ||= %w[aside font span thead tbody tfoot u] 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.rb index 51aac6c3659..a26f8f2313a 100644 --- a/spec/lib/html_to_markdown_spec.rb +++ b/spec/lib/html_to_markdown_spec.rb @@ -527,6 +527,14 @@ RSpec.describe HtmlToMarkdown do line + + + This + is + the + footer + + HTML @@ -535,6 +543,7 @@ RSpec.describe HtmlToMarkdown do | - | - | - | - | | I am | the | **first** | row | | And this | is the | 2nd | line | + | This | is | the | footer | MD expect(html_to_markdown(html)).to eq(markdown.strip) @@ -565,24 +574,24 @@ RSpec.describe HtmlToMarkdown do @@ -592,12 +601,12 @@ RSpec.describe HtmlToMarkdown do @@ -625,14 +634,14 @@ RSpec.describe HtmlToMarkdown do
- + 1 - + - + 2 - + - + 3 - + - + 4 - +
- + **Two** - + Three
@@ -671,31 +680,31 @@ RSpec.describe HtmlToMarkdown do
- + 1 - + - + 2 - +
1 - + - + 2 - +
A - + - + B - +
- + C - +