Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disply two markdown code blocks side by side

Tags:

markdown

I would like to display two blocks of a source codes side by side -before refactoring and after. Is it possible to create two code blocks side by side? If not then what is the alternative solution?

like image 730
Lukasz Dynowski Avatar asked Feb 13 '16 15:02

Lukasz Dynowski


People also ask

Can you do columns in Markdown?

Pandoc's Markdown supports the multi-column layout for slides but not other types of documents. In this recipe, we show how to use the multi-column layout in normal HTML documents and LaTeX documents.

How do I show code snippet in Markdown?

There are two ways to format code in Markdown. You can either use inline code, by putting backticksbackticksThe backtick ` is a typographical mark used mainly in computing. It is also known as backquote, grave, or grave accent. `https://en.wikipedia.org › wiki › BacktickBacktick - Wikipedia (`) around parts of a line, or you can use a code block, which some renderers will apply syntax highlighting to.

How do you indent Markdown code blocks?

To format a code block in Markdown, indent every line of the block by at least four spaces. An indented code block cannot interrupt a paragraph, so you must insert at least one blank line between a paragraph the indented code block that follows.

How do you insert a horizontal line in Markdown?

You can create a horizontal rule ( <hr /> ) by placing 3 or more hyphens, asterisks, or underscores on a single line by themselves. You can also place spaces between them.


1 Answers

There is no way to create multi-line code blocks in a single table cell using bare Markdown syntax - but you can use verbatim HTML to accomplish this. Here is an example two-column table with side-by-side code (note that this HTML goes side-by-side with the rest of your Markdown):

# Document Title

The usual [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
does not cover some of the more advanced Markdown tricks, but here
is one. You can combine verbatim HTML with your Markdown. 
This is particularly useful for tables.
Notice that with **empty separating lines** we can use Markdown inside HTML:

<table>
<tr>
<th>Json 1</th>
<th>Markdown</th>
</tr>
<tr>
<td>
<pre>
{
  "id": 1,
  "username": "joe",
  "email": "[email protected]",
  "order_id": "3544fc0"
}
</pre>
</td>
<td>

```json
{
  "id": 5,
  "username": "mary",
  "email": "[email protected]",
  "order_id": "f7177da"
}
```

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

which is rendered as:

two-column table in markdown

like image 129
charlesreid1 Avatar answered Sep 28 '22 17:09

charlesreid1