Skip to content

Fix index out of bounds exception for HTML tables #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,44 @@ tables with row span cells
````````````````````````````````


table where some rows end with colspan 0

```````````````````````````````` example Tables: 51
| Abc | Def |
|---------|-----|
| no span | span

.
<table>
<thead>
<tr><th>Abc</th><th colspan="1">Def</th></tr>
</thead>
<tbody>
<tr><td>no span</td><td colspan="0">span</td></tr>
</tbody>
</table>
````````````````````````````````


table where all rows end with colspan 0

```````````````````````````````` example Tables: 52
| Abc | Def
|---------|-----|
| no span | span

.
<table>
<thead>
<tr><th>Abc</th><th colspan="0">Def</th></tr>
</thead>
<tbody>
<tr><td>no span</td><td colspan="0">span</td></tr>
</tbody>
</table>
````````````````````````````````


## Definition Lists

a definition in a block quote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;

import static com.vladsch.flexmark.util.format.TableCellManipulator.BREAK;
import static com.vladsch.flexmark.util.misc.Utils.max;
import static com.vladsch.flexmark.util.misc.Utils.maxLimit;
import static com.vladsch.flexmark.util.misc.Utils.minLimit;

Expand Down Expand Up @@ -97,7 +98,7 @@ public int getSpannedColumns() {
int columns = 0;
for (TableCell cell : cells) {
if (cell == null) continue;
columns += cell.columnSpan;
columns += max(cell.columnSpan, 1);
}
return columns;
}
Expand Down