Questions tagged [code-formatting]
For questions about making code appear correctly in questions, answers and comments.
281
questions
399
votes
1
answer
279k
views
How do I format my code blocks?
How do I post text so that it is formatted as code?
What do I need to do so that my code shows up properly — not escaped or removed — when posted? And how to get the correct syntax ...
168
votes
9
answers
11k
views
Code block is not properly formatted when placed immediately after a list item [duplicate]
Consider the following piece of Markdown code:
This is some regular text.
>>> def factorial(n):
... return 1 if n < 2 else n * factorial(n - 1)
...
* This is a list ...
322
votes
5
answers
154k
views
How to nest code within a list using Markdown [duplicate]
Oftentimes, I want to include code samples in a list, for example:
Item One
Item Two, for example:
private bool ItemTwo()
{
return this.IFeelLucky;
}
Item Three
The problem is that there isn't a ...
132
votes
5
answers
4k
views
Inline Code Spans should not be used for emphasis, right?
When reviewing Suggested Edits on Stack Overflow, I often come across "fixed formatting" suggestions that use inline code spans to place emphasis on certain keywords, but isn't actual code.
For ...
317
votes
38
answers
58k
views
Goodbye, Prettify. Hello highlight.js! Swapping out our Syntax Highlighter
Update 2020-09-24
This is now live network-wide.
Update
This is now live on Meta Stack Exchange and Meta Stack Overflow. Any bugs and feedback can be posted here as an answer.
I’m Ben and I’m a dev ...
52
votes
3
answers
1k
views
Allow highlighting certain bits of a code fragment or quote
It would be nice to be able to put emphasis on specific bits of a fragment or of a quote (bold can help for a quote but I find that it makes things less readable sometimes).
What do you think?
Update: ...
167
votes
14
answers
6k
views
Why are there no line numbers in the code listings?
Would it make discussing code easier if you could simply refer to a particular line or range, or am I wrong?
21
votes
1
answer
1k
views
When is it appropriate to edit someone else's code? [duplicate]
Possible Duplicate:
How far can I refactor someone else's code?
I see a lot of edits in queue where some well-meaning user attempts to fix OP's code. They range from minor syntax corrections, to near ...
17
votes
2
answers
545
views
Automatic code reindent button
Often I see code blocks pasted into questions with no formatting, or terrible formatting.
It's sometimes quite a chore to fix these: you have to either manually space out each line, or paste the code ...
17
votes
1
answer
743
views
My comment `code block` was not converted properly, is this a bug?
In my comment here:
https://stackoverflow.com/questions/409/what-is-your-favorite-coding-guidelines-checklist/138993#comment-8835926
I needed to have a : symbol with a leading space, but I couldn't ...
38
votes
1
answer
524
views
User suggested great corrective edit to my answer, but the edit was rejected. What can I do to approve it? [duplicate]
A nice user suggested a good corrective edit to my answer. The edit, though very good and desirable, was rejected. I do not understand the reasons, and I did not find a way to contact those people who ...
12
votes
3
answers
1k
views
Backslash escaping in code regions in comments
I've noticed that in comments, when you create `code region` with backticks, the backslash will still work as an escape character within that region (but it should not, IMHO).
To clarify:
In ...
722
votes
6
answers
345k
views
How do I escape a backtick ` within in-line code in Markdown?
How do I escape a backtick ` within a code block?
This is probably a duplicate, since I'm sure it's a common concern, but I can't find a question that addresses this specifically.
How do I write ...
20
votes
1
answer
954
views
Why do code blocks sometimes not "show" properly?
It's possible that this is a duplicate of this question - but if so, I don't know why, and I can't verify whether it's the case. I've got a concrete example, although only dev (and maybe mods) will be ...
227
votes
5
answers
59k
views
How can the backtick character ` be included in code?
I tried before to post a shell script that contained a ` character as an answer on Stack Overflow. The parser insisted on treating the backtick as formatting instead of part of code.
How can I ...