Do you want to show a table with a multi-line code block on GitHub?
Then follow these golden rules
Unfortunately, a markdown table is not suitable to contain code blocks.
Some markdown editors might show correct layout and syntax highlighting if you use HTML
br elements in your code block. But this is very cumbersome and awkward. And finally, GitHub itself will show the code block on a single line :(
Use a HTML table instead!
Use either backticks (
\\\) or the HTML
pre element with attribute
lang to enclose your code blocks.
Do NOT use HTML
code element as you won't get syntax highlighting.
Keep a blank line before and after a code block for correct formatting and syntax highlighting. Otherwise, your code may show up as a single line and unformatted.
Some of the popular online editors will not accurately preview such a table.
Use TablesGenerator to easily generate either HTML or markdown tables.
Use the following gist as a reference (view raw) and for testing in the markdown editor of your choice