@@ -4410,24 +4410,22 @@ md_analyze_table_alignment(MD_CTX* ctx, OFF beg, OFF end, MD_ALIGN* align, int n
44104410static int md_process_normal_block_contents (MD_CTX * ctx , const MD_LINE * lines , int n_lines );
44114411
44124412static int
4413- md_process_table_cell (MD_CTX * ctx , MD_BLOCKTYPE cell_type , MD_ALIGN align , OFF beg , OFF end )
4413+ md_process_table_cell (MD_CTX * ctx , MD_BLOCKTYPE cell_type , MD_BLOCK_TD_DETAIL * det , OFF beg , OFF end )
44144414{
44154415 MD_LINE line ;
4416- MD_BLOCK_TD_DETAIL det ;
44174416 int ret = 0 ;
44184417
44194418 while (beg < end && ISWHITESPACE (beg ))
44204419 beg ++ ;
44214420 while (end > beg && ISWHITESPACE (end - 1 ))
44224421 end -- ;
44234422
4424- det .align = align ;
44254423 line .beg = beg ;
44264424 line .end = end ;
44274425
4428- MD_ENTER_BLOCK (cell_type , & det );
4426+ MD_ENTER_BLOCK (cell_type , det );
44294427 MD_CHECK (md_process_normal_block_contents (ctx , & line , 1 ));
4430- MD_LEAVE_BLOCK (cell_type , & det );
4428+ MD_LEAVE_BLOCK (cell_type , det );
44314429
44324430abort :
44334431 return ret ;
@@ -4438,6 +4436,10 @@ md_process_table_row(MD_CTX* ctx, MD_BLOCKTYPE cell_type, OFF beg, OFF end,
44384436 const MD_ALIGN * align , int col_count )
44394437{
44404438 MD_LINE line ;
4439+ MD_LINE cell ;
4440+ MD_BLOCK_TD_DETAIL det ;
4441+
4442+ unsigned is_spans ;
44414443 OFF * pipe_offs = NULL ;
44424444 int i , j , k , n ;
44434445 int ret = 0 ;
@@ -4464,19 +4466,36 @@ md_process_table_row(MD_CTX* ctx, MD_BLOCKTYPE cell_type, OFF beg, OFF end,
44644466 MD_MARK * mark = & ctx -> marks [i ];
44654467 pipe_offs [j ++ ] = mark -> end ;
44664468 }
4467- pipe_offs [j ++ ] = end + 1 ;
4469+ pipe_offs [j ] = end + 1 ;
44684470
4471+ is_spans = ctx -> parser .flags & MD_FLAG_TABLE_CELLSPAN ;
44694472 /* Process cells. */
44704473 MD_ENTER_BLOCK (MD_BLOCK_TR , NULL );
44714474 k = 0 ;
4472- for (i = 0 ; i < j - 1 && k < col_count ; i ++ ) {
4473- if (pipe_offs [i ] < pipe_offs [i + 1 ]- 1 )
4474- MD_CHECK (md_process_table_cell (ctx , cell_type , align [k ++ ], pipe_offs [i ], pipe_offs [i + 1 ]- 1 ));
4475+ for (i = 0 ; i < j && k < col_count ; i ++ ) {
4476+ cell .beg = pipe_offs [i ];
4477+ cell .end = pipe_offs [i + 1 ]- 1 ;
4478+
4479+ if (cell .beg < cell .end ) {
4480+ det .colspan = 0 ;
4481+ if (is_spans && cell .end - cell .beg >= 2 &&
4482+ ISDIGIT (cell .beg ) && CH (cell .beg + 1 ) == '>' ) {
4483+ det .colspan = CH (cell .beg ) - '0' ;
4484+ cell .beg += 2 ;
4485+ }
4486+ det .align = align [k ++ ];
4487+ MD_CHECK (md_process_table_cell (ctx , cell_type , & det , cell .beg , cell .end ));
4488+ if (is_spans && det .colspan > 1 )
4489+ k += det .colspan - 1 ;
4490+ }
44754491 }
44764492 /* Make sure we call enough table cells even if the current table contains
44774493 * too few of them. */
4478- while (k < col_count )
4479- MD_CHECK (md_process_table_cell (ctx , cell_type , align [k ++ ], 0 , 0 ));
4494+ det .colspan = 0 ;
4495+ while (k < col_count ) {
4496+ det .align = align [k ++ ];
4497+ MD_CHECK (md_process_table_cell (ctx , cell_type , & det , 0 , 0 ));
4498+ }
44804499 MD_LEAVE_BLOCK (MD_BLOCK_TR , NULL );
44814500
44824501abort :
0 commit comments