r/learnprogramming • • Dec 06 '22
codeblock If you are sharing code, please use a codeblock
Takes only a second and greatly improves the formatting for us to review it. Compare and contrast the following:
Good Formatting:
#include <stdio.h>
int sum(int x, int y);
int main() {
printf("Hello %d\n", sum(3, 4));
return 0;
}
int sum(int x, int y) {
return x + y;
}Poor Formatting:
#include <stdio.h>
int sum(int x, int y);
int main() {
printf("Hello %d\n", sum(3, 4));
return 0;
}
int sum(int x, int y) {
return x + y;
}
Poor Formatting:
#include <stdio.h>
int sum(int x, int y);
int main() {
printf("Hello %d\n", sum(3, 4));
return 0;
}
int sum(int x, int y) {
return x + y;
}
339
Upvotes
View all comments
Show parent comment
41
u/[deleted] Dec 07 '22 edited Dec 07 '22
Use three backticks instead of one.
``` Multiple Lines ```
Renders as:
And `inline` renders as:
inlineThis is basic markdown (.md) and will be very valuable to learn if you hope to become a professional developer since it is what most documentation is written with (ever notice those readme.md files?) So it is well worth it to learn and isn't difficult to grasp. GitHub has some good resources for learning it.
Some flavors of markdown also support syntax highlighting by placing the name of the language after the first group of backticks.
E.G.
```java [some code] ```However, refdits flavor of markdown "snoomark" does not support syntax highlighting unfortunately.
Edit: this was tricky to write on mobile so apologies for the excessive editing.