Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown: Problems with numbered list paragraphs containing code element

I created a README.md file on GitHub and there are some markdown problems I can't find a solution to.

When I enter this (The dots represent space signs):

Instructions:..
....1. First sentence..
....2. Second sentence..

........This is some code.

....3. Third sentence..
....4. Fourth sentence

It renders to this:

Instructions:
1. First sentence
2. Second sentence

    This is some code.

3. Third sentence
4. Fourth sentence

How can I separate the code block from the numbered list?

I would also like to know how I can tell Markdown to ignore Markdown syntax so I don't have to use dots as a representation of space signs.

like image 200
Christian Heinrichs Avatar asked Sep 26 '13 19:09

Christian Heinrichs


People also ask

How do you mark some text as code inside a paragraph in Markdown?

To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input: This is a normal paragraph: This is a code block. A code block continues until it reaches a line that is not indented (or the end of the article).

How do I specify code in Markdown?

There are two ways to format code in Markdown. You can either use inline code, by putting backticks (`) around parts of a line, or you can use a code block, which some renderers will apply syntax highlighting to.

How do you insert a paragraph in Markdown?

Paragraphs. To create paragraphs in Markdown, use one or more lines of consecutive text followed by one or more blank lines. Note: If you don't leave a blank line between blocks of text, they will be collapsed into a single paragraph.

How do you indent code block Markdown?

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.


1 Answers

How about this?

Instructions:

1. First sentence
2. Second sentence

    `This is some code.`

3. Third sentence
4. Fourth sentence

It wouldn't indent each point, however your example with the dots doesn't do it either. If the spacing between Instructions: and the rest is not what you want, you can use the double space after it and on the two following lines.

UPDATE: After a little fiddling, if you want to keep the numbering of the list and put some code that's relative to a single item on the list you should indent the code block. Also, have a new line before the first element of the list seems to help.

like image 188
Mathieu Avatar answered Jan 04 '23 08:01

Mathieu