Markdown – Embedding Code Snippets In Code Snippet

When tried to show how to insert code snippets in markdown, I found that I didn’t know how to insert code sinppets in code snippet.

Helped by Google, I finally got the solution.

We can embed code snippets into Markdown text by:

  1. intending 4 or more spaces, or a tab as code block
  2. using triple backticks plus a syntax language code delimiter at the beginning and triple backticks at the end of code block

Interactive use of the two ways can help us write a demo of inserting code in markdown.

For example, we can intend tabs before backticks blocks:

The result is:

And We can also intend tabs in backticks blocks:

The result:

The short of this way is that the tabs cannot be eliminated.

Add backticks pairs in backticks pairs will produce wrong format. Em, you can have a try.


Embedding Code Snippets


Leave a Reply