How to write lists inside a markdown table?
Solution 1
Yes, you can merge them using HTML. When I create tables in .md
files from Github, I always like to use HTML code instead of markdown.
Github Flavored Markdown supports basic HTML in .md
file. So this would be the answer:
Markdown mixed with HTML:
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
| <ul><li>item1</li><li>item2</li></ul>| See the list | from the first column|
Or pure HTML:
<table>
<tbody>
<tr>
<th>Tables</th>
<th align="center">Are</th>
<th align="right">Cool</th>
</tr>
<tr>
<td>col 3 is</td>
<td align="center">right-aligned</td>
<td align="right">$1600</td>
</tr>
<tr>
<td>col 2 is</td>
<td align="center">centered</td>
<td align="right">$12</td>
</tr>
<tr>
<td>zebra stripes</td>
<td align="center">are neat</td>
<td align="right">$1</td>
</tr>
<tr>
<td>
<ul>
<li>item1</li>
<li>item2</li>
</ul>
</td>
<td align="center">See the list</td>
<td align="right">from the first column</td>
</tr>
</tbody>
</table>
This is how it looks on Github:
Solution 2
If you want a no-bullet list (or any other non-standard usage) or more lines in a cell use <br />
| Event | Platform | Description |
| ------------- |-----------| -----:|
| `message_received`| `facebook-messenger`<br/>`skype`|
Solution 3
Not that I know of, because all markdown references I am aware of, like this one, mention:
Cell content must be on one line only
You can try it with that Markdown Tables Generator (whose example looks like the one you mention in your question, so you may be aware of it already).
Pandoc
If you are using Pandoc’s markdown (which extends John Gruber’s markdown syntax on which the GitHub Flavored Markdown is based) you can use either grid_tables
:
+---------------+---------------+--------------------+ | Fruit | Price | Advantages | +===============+===============+====================+ | Bananas | $1.34 | - built-in wrapper | | | | - bright color | +---------------+---------------+--------------------+ | Oranges | $2.10 | - cures scurvy | | | | - tasty | +---------------+---------------+--------------------+
or multiline_tables
.
------------------------------------------------------------- Centered Default Right Left Header Aligned Aligned Aligned ----------- ------- --------------- ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. -------------------------------------------------------------
Solution 4
another solution , you can add <br>
tag to your table
|Method name| Behavior |
|--|--|
| OnAwakeLogicController(); | Its called when MainLogicController is loaded into the memory , its also hold the following actions :- <br> 1. Checking Audio Settings <br>2. Initializing Level Controller|
Solution 5
An alternative approach, which I've recently implemented, is to use the div-table plugin with panflute.
This creates a table from a set of fenced divs (standard in the pandoc implementation of markdown), in a similar layout to html:
---
panflute-filters: [div-table]
panflute-path: 'panflute/docs/source'
---
::::: {.divtable}
:::: {.tcaption}
a caption here (optional), only the first paragraph is used.
::::
:::: {.thead}
[Header 1]{width=0.4 align=center}
[Header 2]{width=0.6 align=default}
::::
:::: {.trow}
::: {.tcell}
1. any
2. normal markdown
3. can go in a cell
:::
::: {.tcell}
![](https://pixabay.com/get/e832b60e2cf7043ed1584d05fb0938c9bd22ffd41cb2144894f9c57aae/bird-1771435_1280.png?attachment){width=50%}
some text
:::
::::
:::: {.trow bypara=true}
If bypara=true
Then each paragraph will be treated as a separate column
::::
any text outside a div will be ignored
:::::
Looks like:
Related videos on Youtube
Comments
-
Gabriel Petrovay almost 2 years
Can one create a list (bullets, numbered or not) inside a markdown table.
A table looks like this:
| Tables | Are | Cool | | ------------- |:-------------:| -----:| | col 3 is | right-aligned | $1600 | | col 2 is | centered | $12 | | zebra stripes | are neat | $1 |
A list looks like this:
* one * two * three
Can I merge them somehow?
-
Gabriel Petrovay over 10 yearsThe Markdown Tables Generator is wrong because it accepts new lines that, as you quote, are not accepted. But thanks for the valuable information.
-
VonC over 10 years@GabrielPetrovay The Markdown Tables Generator being a relatively new service, I am not surprised ;) But regarding "GitHub Flavored Markdown", my answer stands.
-
Gabriel Petrovay over 10 yearsI tend to accept your answer. But I wait 1-2 days more, maybe someone posts a hack (if answer accepted, no one will look at it, except others with the same problem)
-
VonC over 10 years@GabrielPetrovay I agree. You also can contact GitHub support, and see what they have to say about it. (and then update my answer or post your own)
-
Gabriel Petrovay over 10 yearsDone! Also instructed them to reply here :) with a comment or a new answer.
-
VonC over 10 years@イオニカビザウ I obviously didn't mentioned HTML. With HTML, you can recreate any markdown feature, so it is not a valid solution. The question is about markdown, not HTML.
-
Ionică Bizău over 10 years@VonC I saw that is tagged as
github-flavored-markdown
. Github Flavored markdown supports HTML. -
Trebor Rude over 9 yearsThis is great, but is there any way to style the list too? Remove bullets, margins, etc.? Github, for example, doesn't seem to accept a
style="list-style: none"
tag on theul
element. -
Ionică Bizău over 9 years@TreborRude No, because Markdown is not HTML actually. But if you use a library (e.g.
marked
), you probably have this feature (to combine HTML with markdown). -
Trebor Rude over 9 yearsIt's ok, I found out that a
<span>
tag with embedded<br/>
tags did exactly what I was trying to do with the styled list. -
Ionică Bizău over 9 years@TreborRude Sure, you still can have multiple line cells. Probably it accepts
<p>
tags as well. -
nwinkler over 7 yearsI'm happy to confirm that the first one (embedded
<ul><li>foo</li></ul>
) also works on Bitbucket Server. -
William Daniel about 7 yearsProbably because three years ago it was the only reasonable answer? I agree with you that this is a better answer, today.
-
Bergi almost 7 yearsThis is an answer to Newline in markdown table?, not this question about lists
-
Amio.io almost 7 years@Bergi I've upvoted your suggestion. ;) The google search led me to this question and this the solution I needed. I think it's bearable (e.g. non-bulleted list) so I keep it at this very place.
-
shawnhcorey over 6 yearsYou can add bullets with HTML entities: •
facebook-messenger
<br/>•skype
-
andrei.ciprian about 6 yearsmarkdown lint flags this as no inline html
-
user3613932 almost 4 yearsUse
ol
if you need ordered lists. Example<ol><li>Enumeration 1<li><li>Enumeration 2</li></ol>
. -
mavericks almost 4 years@VonC if I use your
grid_tables
code in an Rmd file and use knitr to generate PDF output, the table contains a blank line after each list for some reason. Any idea why this is the case or how to circumvent this (pandoc) behavior? -
VonC almost 4 years@mavericks 7 years later.... no precise idea, really: try and ask a separate question, with illustration of the bug.
-
XenGi almost 3 yearsHTML will ignore blank lines and multiple whitespaces, so I don't see any problems with that. Could you explain what will break here?
-
Ken Ingram about 2 yearsPerfect. Exactly what I needed. And it stays with Markdown instead of adding extraneous stuff to solve a simple problem.
-
Manny Ma almost 2 yearsnot sure but can this be done in rmarkdown?