@@ -3379,7 +3379,7 @@ def run(self, text):
3379
3379
(?:
3380
3380
^[ ]{0,%d}(?!\ ) # ensure line begins with 0 to less_than_tab spaces
3381
3381
.*\|.*[ ]*\n
3382
- )+
3382
+ )*
3383
3383
)
3384
3384
''' % (less_than_tab , less_than_tab , less_than_tab ), re .M | re .X )
3385
3385
return table_re .sub (self .sub , text )
@@ -3415,17 +3415,19 @@ def sub(self, match: re.Match) -> str:
3415
3415
hlines .append ('</thead>' )
3416
3416
3417
3417
# tbody
3418
- hlines .append ('<tbody>' )
3419
- for line in body .strip ('\n ' ).split ('\n ' ):
3420
- hlines .append ('<tr>' )
3421
- cols = [re .sub (escape_bar_re , '|' , cell .strip ()) for cell in re .split (split_bar_re , re .sub (trim_bar_re , "" , re .sub (trim_space_re , "" , line )))]
3422
- for col_idx , col in enumerate (cols ):
3423
- hlines .append (' <td{}>{}</td>' .format (
3424
- align_from_col_idx .get (col_idx , '' ),
3425
- self .md ._run_span_gamut (col )
3426
- ))
3427
- hlines .append ('</tr>' )
3428
- hlines .append ('</tbody>' )
3418
+ body = body .strip ('\n ' )
3419
+ if body :
3420
+ hlines .append ('<tbody>' )
3421
+ for line in body .split ('\n ' ):
3422
+ hlines .append ('<tr>' )
3423
+ cols = [re .sub (escape_bar_re , '|' , cell .strip ()) for cell in re .split (split_bar_re , re .sub (trim_bar_re , "" , re .sub (trim_space_re , "" , line )))]
3424
+ for col_idx , col in enumerate (cols ):
3425
+ hlines .append (' <td{}>{}</td>' .format (
3426
+ align_from_col_idx .get (col_idx , '' ),
3427
+ self .md ._run_span_gamut (col )
3428
+ ))
3429
+ hlines .append ('</tr>' )
3430
+ hlines .append ('</tbody>' )
3429
3431
hlines .append ('</table>' )
3430
3432
3431
3433
return '\n ' .join (hlines ) + '\n '
0 commit comments