How to write multi-line code blocks?
-
I would like to write a multi-line code block. However, my line breaks are replaced by blanks. I use the backticks (inverted apostrophe) to start and end code blocks. How the description in the markdown documentation is related to this forum is a mystery to me:
To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab.
The following text always starts with 4 spaces:
This is a text of markdown
Line starts with 4 spaces and should be displayed as a code blockWhen starting and ending a block with a single backtick, I get:
First line of code block second line of test code block
Test using two backticks each at the start and end of the code block:
First line of code block second line of test code block
-
Hi,
For "complex code block" it's three back-ticks e.g.
First line Second line etc.
-
second line of code``` Hmmm...doesn't work.
-
Another test:
Code block line 1 Code block line 2 #include something
Ah, so I need to have three backticks and a line break. Thanks for the pointer.
-
Because you're missing line breaks.
It's:three back-ticks, new-line,
your multi-line code, new-line,
three back-ticks, new-lineYour text etc.
-
You're welcome !
By the way, there's also the new "mark as solved" technique since the latest update of the forum. You don't need to update the thread title anymore, now you can use the "Topic Tool" button thus keeping the thread slug clean :)
-
Strangeā¦
I've updated it for you