Skip to content

Markdown tables not parsed correctly

Summary

Gitlab flavored markdown does not render the following code as a table:

| id | name | email | bal | 
| -: | - | - | -: | 
| 5 | chris | foo | 12089 | 

Expected behavior

That code is properly rendered as a table in Github, dillinger.io, stackedit.io.

Actual behavior

Gitlab renders as a line of plain text like so:

| id | name | email | bal | | -: | - | - | -: | | 5 | chris | foo | 12089 |

Possible fixes

Currently, the separating line needs at least three dashes for each cell to be rendered as a table in Gitlab:

With three dashes:

| id | name | email | bal | 
| ---: | --- | --- | ---: | 
| 5 | chris | foo | 12089 | 

Renders:

id name email bal
5 chris foo 12089

According to the documentation, Gitlab uses the Redcarpet Ruby library for markdown parsing. Looking at this issue from that repo, they do not require the three dashes for table separators, so I wasn't sure why Gitlab does.