How to add a checkbox within a markdown table in Gitlab?
Asked Answered
P

2

7

I am trying to set up a table in markdown that I can store in a Gitlab Wiki.

The table looks something like this:

| Col1 | Col2 | Col 3 | Col4 |
| :---: | :---: | :---: | --- |
| ID1 | Yes | No | some text |

Here is how the table looks:

Col1 Col2 Col 3 Col4
ID1 Yes No some text

What I would like to do instead of editing and changing the cell to be Yes or No manually, that I could use a checkbox, normally "- [ ]" should work but apparently does not work inside of table.

Pullman answered 7/5, 2021 at 9:44 Comment(2)
Not exactly the same. But people coming here may also be interested in #31695371.Benia
Doesn't seem to be supported right now: gitlab.com/gitlab-org/gitlab/-/issues/21506Dolliedolloff
L
0

The following creates clickable checkboxes when pasted to GitLab markdown.

In one of the comments to the GL issue about this Brett Walker proposes the following solution: hand-coding the HTML table with the markdown checkboxes.

<table>
<thead>
<tr>
<th>Checkbox</th>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>

- [ ] done

</td>
<td>Foo</td>
<td>Bar</td>
</tr>
<tr>
<td>

- [x] done

</td>
<td>Foo</td>
<td>Bar</td>
</tr>
</tbody>
</table>

a screenshot of the html code rendered inside GitLab

This is EXACTLY the code that you need to start with! Remove a single newline in the wrong place or add a space somewhere where it shouldn't be, and you might end up with the checkboxes broken. It's very brittle.

Stacking checkboxes horizontally with this also works 🎉.

<table>
<thead>
<tr>
<th>Checkbox 1</th>
<th>Checkbox 2</th>
<th>Checkbox 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>

- [ ] foo

</td>
<td>

- [ ] bar

</td>
<td>

- [ ] baz

</td>
</tr>
</tbody>
</table>

enter image description here

Legge answered 24/5, 2024 at 9:26 Comment(0)
P
-1

maybe this would help you.

|     | name | age | gender |
| --- | ---- | --- | ------ |
| 1   | Bob  | 38  | male   | \ |
| 2   | PJ   | 12  | male   |

But it depends on the interpreter. It works on some editor while not stack overflow

name age gender
1 - [ ] Bob - [ ] 38 - [ ] male
2 - [ ] PJ - [ ] 12 - [ ] male
Phonation answered 20/7, 2024 at 1:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.