Skip to content

Headless tables break extension #161

Open
@arjangeertsema

Description

@arjangeertsema

With this version the code breaks when headless tables are used:

cannot read properties of null (reading 'colsnum') in patterns.js line 175:

const calc = tokens[idx].meta.colsnum >> 0;

This bug appears in combination with markdown-it-multimd-table headerless option.

.use(require('markdown-it-multimd-table'), { headerless: true });
.use(require("markdown-it-attrs"))

proposed fix:

Add null check.

const calc = tokens[idx].meta?.colsnum >> 0;

Markdown-it versions: 4.3.0

Example input:

| - | - |
| a | b |
| c | d |

Current output:

cannot read properties of null (reading 'colsnum') in patterns.js line 175:

Expected output:

<tbody>
<tr>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td>c</td>
<td>d</td>
</tr>
</tbody>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions