From 9c40aa5798af280f4239da998a75c02b37a02b2d Mon Sep 17 00:00:00 2001 From: Thomas Leitner Date: Sun, 17 Nov 2024 12:38:00 +0100 Subject: [PATCH] Fix exception in HTML table parsing when table is empty --- lib/kramdown/parser/html.rb | 2 +- test/testcases/block/09_html/html_to_native/table_simple.html | 3 +++ test/testcases/block/09_html/html_to_native/table_simple.text | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/kramdown/parser/html.rb b/lib/kramdown/parser/html.rb index 23986d52..9fe57518 100644 --- a/lib/kramdown/parser/html.rb +++ b/lib/kramdown/parser/html.rb @@ -534,7 +534,7 @@ def is_simple_table?(el) end end check_nr_cells.call(el) - return false if nr_cells == -1 + return false if nr_cells == -1 || nr_cells == 0 alignment = nil check_alignment = proc do |t| diff --git a/test/testcases/block/09_html/html_to_native/table_simple.html b/test/testcases/block/09_html/html_to_native/table_simple.html index 88d9e6c3..0567d738 100644 --- a/test/testcases/block/09_html/html_to_native/table_simple.html +++ b/test/testcases/block/09_html/html_to_native/table_simple.html @@ -59,3 +59,6 @@ + + +
diff --git a/test/testcases/block/09_html/html_to_native/table_simple.text b/test/testcases/block/09_html/html_to_native/table_simple.text index ae7852b1..7d294304 100644 --- a/test/testcases/block/09_html/html_to_native/table_simple.text +++ b/test/testcases/block/09_html/html_to_native/table_simple.text @@ -69,3 +69,6 @@ Some more + + +