Skip to content

Commit ccbe70b

Browse files
committed
🐛 FIX: Table edge cases
- Fix tables inside lists indented with tabs (implements: markdown-it/markdown-it@75fe6e0) - Table with no columns is no longer a table (implements: markdown-it/markdown-it@b56eeb0)
1 parent 8901a52 commit ccbe70b

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

markdown_it/rules_block/table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def getLine(state: StateBlock, line: int):
13-
pos = state.bMarks[line] + state.blkIndent
13+
pos = state.bMarks[line] + state.tShift[line]
1414
maximum = state.eMarks[line]
1515

1616
# return state.src.substr(pos, max - pos)
@@ -125,7 +125,7 @@ def table(state: StateBlock, startLine: int, endLine: int, silent: bool):
125125
# header row will define an amount of columns in the entire table,
126126
# and align row should be exactly the same (the rest of the rows can differ)
127127
columnCount = len(columns)
128-
if columnCount != len(aligns):
128+
if columnCount == 0 or columnCount != len(aligns):
129129
return False
130130

131131
if silent:

tests/test_port/fixtures/tables.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,53 @@ Escape before escaped Pipes inside backticks don't split cells:
658658
</table>
659659
.
660660

661+
Regression test for #721, table in a list indented with tabs:
662+
.
663+
- Level 1
664+
665+
- Level 2
666+
667+
| Column 1 | Column 2 |
668+
| -------- | -------- |
669+
| abcdefgh | ijklmnop |
670+
.
671+
<ul>
672+
<li>
673+
<p>Level 1</p>
674+
<ul>
675+
<li>
676+
<p>Level 2</p>
677+
<table>
678+
<thead>
679+
<tr>
680+
<th>Column 1</th>
681+
<th>Column 2</th>
682+
</tr>
683+
</thead>
684+
<tbody>
685+
<tr>
686+
<td>abcdefgh</td>
687+
<td>ijklmnop</td>
688+
</tr>
689+
</tbody>
690+
</table>
691+
</li>
692+
</ul>
693+
</li>
694+
</ul>
695+
.
696+
697+
Table without any columns is not a table, #724
698+
.
699+
|
700+
|
701+
|
702+
.
703+
<p>|
704+
|
705+
|</p>
706+
.
707+
661708
GFM 4.10 Tables (extension), Example 198
662709
.
663710
| foo | bar |

0 commit comments

Comments
 (0)