diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index d946d2c..8be7668 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -748,6 +748,15 @@ def convert_th(self, el, text, parent_tags):
def convert_tr(self, el, text, parent_tags):
cells = el.find_all(['td', 'th'])
is_first_row = el.find_previous_sibling() is None
+ if is_first_row and el.parent.name in ('tbody', 'tfoot'):
+ # A new row group continues the same Markdown table.
+ is_first_row = not any(
+ sibling.name == 'tr' or (
+ sibling.name in ('thead', 'tbody', 'tfoot')
+ and sibling.find('tr', recursive=False) is not None
+ )
+ for sibling in el.parent.previous_siblings
+ )
is_headrow = (
all([cell.name == 'th' for cell in cells])
or (el.parent.name == 'thead'
diff --git a/tests/test_tables.py b/tests/test_tables.py
index 7e0670c..7b19977 100644
--- a/tests/test_tables.py
+++ b/tests/test_tables.py
@@ -319,3 +319,24 @@ def test_table_infer_header():
assert md(table_with_colspan, table_infer_header=True) == '\n\n| Name | | Age |\n| --- | --- | --- |\n| Jill | Smith | 50 |\n| Eve | Jackson | 94 |\n\n'
assert md(table_with_undefined_colspan, table_infer_header=True) == '\n\n| Name | Age |\n| --- | --- |\n| Jill | Smith |\n\n'
assert md(table_with_colspan_missing_head, table_infer_header=True) == '\n\n| Name | | Age |\n| --- | --- | --- |\n| Jill | Smith | 50 |\n| Eve | Jackson | 94 |\n\n'
+
+
+def test_multiple_table_bodies_share_a_header():
+ html = ('
')
+ assert md(html) == '\n\n| |\n| --- |\n| A |\n| B |\n\n'
+ assert md(html, table_infer_header=True) == '\n\n| A |\n| --- |\n| B |\n\n'
+
+
+def test_header_cells_in_later_body_do_not_repeat_separator():
+ html = ('')
+ assert md(html) == '\n\n| Heading |\n| --- |\n| A |\n| B |\n\n'
+
+
+def test_footer_after_direct_rows_does_not_repeat_header():
+ html = ('')
+ assert md(html) == '\n\n| Heading |\n| --- |\n| Total |\n\n'