I generally use four spaces, but I use ```
whenever necessary
Four spaces is very good. Actually, I do not use four spaces, but the shortcut offered by Stack Exchange (Ctrl + K). It clearly takes much less time than using ```
.
However, there are two main drawback of using
that I can see
Switching code language
Suppose that I want to post a C code,
#include <stdio.h>
int main() {
printf("Hello, world!\n");
}
I have to use a very long string
<!-- language: lang-cpp -->
but if I use the ```
syntax, I just have to use
```cpp
Clearly the ```
syntax is much better here.
Listings inside a list
Have you ever tried to post a code inside a list environment, like the above codes?
Note that you must indent your code by eight spaces!
* This is some text in a list environment
This is some code
Unfortunately, the Ctrl + K or the {}
button don't work here. If I use those shortcuts for the above C code, the result will be
include
int main() {
printf("Hello, world!\n");
}
This is where the ```
syntax shows its greatest benefit. I just have to use the shortcut to add four spaces and add the backticks to the indented listing. Result
This is where the <code>```</code> syntax shows its greatest benefit. I just
have to use the shortcut to add four spaces and add the backticks to the
indented listing. Result
```cpp
#include <stdio.h>
int main() {
printf("Hello, world!\n");
}
```
#include <stdio.h>
int main() {
printf("Hello, world!\n");
}
Of course, with a higherlevel list, like this
This is some code
\documentclass{article}
it requires more spare time to manually insert spaces.
However I disagree with the linked revision in case it is from another user
The user who made the revision is the answerer himself, so any edits are very acceptable and welcome. However, please note that your suggested edit will be rejected by me in the review queue if you propose such an edit.
The following part does not criticize the answerer – he just edits his post, so nothing is wrong here. I appreciate his revision. But the part criticizes all suggested edits with this style.
Please do NOT propose useless suggested edits just for substituting four spaces with backticks!
I will reject all such edit suggests.
The linked revision has three parts:
- Substitute four spaces with backticks: I disagree with it. What is wrong with four spaces?
- Add
>
to the quote: Well, how does the output change then? Is it okay to have a multiline paragraph code with only >
? Absolutely okay, so I disagree with this also.
According to package [wrapfig][1]
to According to [wrapfig][1] documentation
: Alright, this is at least acceptable, but that is not a major edit and not so necessary.
In short, if it is from a user less than 2000 rep and not the post owner, I will reject it right away.
{}
technique, since it's provided as an option for the question and answer boxes, and is easy to describe.<!-- language: lang-latex -->
, and I never remembered if it'slang-latex
orlatex-lang
, while now you just write the language name after the code fence. 2) I found it really annoying that whatever last-minute line break I decided to add to the code I had to put 4 spaces before it, while now the code remains as it should be.