Questions tagged [code]
Questions relating to code that appears in a question or answer, such as answers which are entirely code. Do not use this tag for questions about code formatting; use [code-formatting] instead - and NEVER EVER USE THIS TAG TO ASK A PROGRAMMING QUESTION ON META!.
138
questions
-2
votes
0
answers
47
views
I'm trying to submit an answer to SO, but it is improperly formatted no matter what I do [closed]
I'm trying to submit an answer to SO, but the code snippet is always rejected as improperly formatted. Everything I've tried fails, from 4 space indentation to using the "code" button in ...
12
votes
0
answers
118
views
Why do we still have strange escape backslashes appearing in question code?
I was wondering why would users have that weird backslashes when pasting code. Now I noticed that this is a persisting issue1, 2, 3. Why hasn't this been solved yet? See here. I've edited several ...
-16
votes
2
answers
165
views
How should I write my question about margins not working?
I have a question about my Stack Overflow post: Why are margins not working in my HTML file and how can I fix that?
I have a problem with my HTML file, but I can't figure out how I should ask about it....
246
votes
1
answer
73k
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 do I get the correct syntax ...
2
votes
1
answer
207
views
Code searching at the end of 2022
Tl;Dr:
As of November 2022, is Google still the best option to search for posts including specific code methods?
I'm trying to find questions with code generated by the Google Sheets Macro Recorder. ...
-17
votes
2
answers
267
views
Should I edit posts with improved style? [duplicate]
I edited this answer on Stack Overflow and improved its format, so it's easier to read and conforms to Python best style/format practices. Is it a good edit or not?
It used to look like this
return ...
25
votes
6
answers
2k
views
Should we edit a question to transcribe code from an image to text?
Context: "How to call a method from a class referenced as a string?"
More general context: how do we educate occasional users, or new users, to the best practices to follow when posting a ...
29
votes
2
answers
1k
views
Should code from pastebin be edited into a question? [duplicate]
Sometimes when I review edits in the Suggested Edits queue, code or text from a linked pastebin is edited into the question. Is this encouraged? Should this be approved?
6
votes
2
answers
497
views
Is it possible to add a CSS compiler/transpiler (Sass or Less) in stack code snippets?
We need to support a CSS compiler - Sass and Less. If CSS compilers are not supported on Stack Overflow code snippet which must be included. If it can't be supported in stack code snippets, allow ...
3
votes
0
answers
108
views
Why are strange backslashes (escapes?) suddenly appearing in rendered code? [duplicate]
I've noticed that lately strange backslashes are appearing more and more frequently in edited code.
Here is another example. Is this a user failure or a bug in the site's code rendering?
36
votes
0
answers
522
views
Punctuation characters being escaped in code
For the past couple of days, it seems that when users paste code into their questions, but don't put it into a proper code block, many punctuation characters are being automatically escaped with ...
-9
votes
2
answers
206
views
Piece-of-code-highlight/error highlight for Stack Overflow (and possibly others)
Similar questions
I have checked some previous questions/answers like this one: Highlight Line of Code
But I did not like the answer and this can be troublesome.
Proposal
Let's say I post a big (but ...
20
votes
2
answers
1k
views
Answers with large amounts of code (whole scripts)
I answered a question (since closed: "This question needs debugging details. It is not currently accepting answers," and deleted) a little while ago, and it really is a good answer, because ...
1
vote
0
answers
143
views
While editing a question, this piece of text causes the error: "contain code that is not properly formatted"
I am editing one of my questions on Stack Overflow.
It raises an error:
Your post appears to contain code that is not properly formatted as
code.
After some digging, I find it is about this text:
(...
10
votes
1
answer
411
views
Should I reject or approve this code edit suggestion? [duplicate]
I've already read main question on this topic, When should I make edits to code? and this one too, still I'm not sure what to do with this edit suggestion:
https://stackoverflow.com/review/suggested-...
-7
votes
3
answers
410
views
Copy button on code blocks [duplicate]
This question keeps coming up every here at meta and it gets positive responses.
Yet it has not been implemented yet.
Why?!
Using a phone and copy pasting a code block is a true nightmare!
Sometimes ...
-5
votes
1
answer
308
views
Require image of Scratch script for Scratch questions
It's hard to visualize a script in visual programming language like Scratch. Here's an example of what I mean:
The correct way to make an infinite loop without the forever block is to use the repeat ...
77
votes
9
answers
6k
views
Should questions about obfuscated code be off-topic?
Per another Meta it came to our attention that there was a user posting potentially malicious code. There's no real rule about that, but, for unrelated reasons of moderation, the account that posted ...
17
votes
0
answers
301
views
Add a means for tab stacking code snippets
The vast majority of questions on Stack Overflow come with a specific language tag and no post in the tag will contain any language other than that specified language.
However, for some questions are ...
4
votes
1
answer
207
views
Strange code highlighting issue in C# code
In this post:
How to identify html tags in html string
The language is not being recognized, the first string inside the quotes and the comments are all off.
When I try to answer, the same strange ...
1
vote
0
answers
43
views
Can we re-open code (stack snippets) in the code editor? [duplicate]
For example, given the following code snippet, how does one edit the question or answer and open the existing example inside the code editor again?
console.log('example')
h1 {
color: deeppink;
}...
12
votes
1
answer
203
views
Which flag should I use for too much code? [duplicate]
I just got the privilege to edit or review questions and answers. Now I'm faced with the question: what flag is the right one, when the question includes too much code?
Surely Needs author edit, but ...
7
votes
0
answers
91
views
Triple-backtick code blocks don't get blockquoted correctly
Suppose I have a code block like this contrived pseudocode:
```
Here {
is
}
my code
```
When I select the whole block including the backticks and then use try to blockquote it using the button or ...
2
votes
0
answers
79
views
Fix an unknown bug, copy all the code or give a link? [duplicate]
I am gradually starting to learn all the publishing rules in Stack Overflow.
I understood that it was necessary to publish as much explanation as possible by publishing this code without putting only ...
27
votes
3
answers
411
views
Can we please have a shortcut for "Do not post code or errors as images"?
I find myself typing this phrase multiple times a day. A shortcut that led directly to the FAQ explanation would be really helpful.
2
votes
0
answers
95
views
Do I need to license my code under GPL if I use code from Stack Overflow? [duplicate]
From the licensing page:
Content contributed on or after 2018-05-02 (UTC) is distributed under the terms of CC BY-SA 4.0.
When I looked on the Creative-Commons page describing the license, I found ...
13
votes
2
answers
610
views
What's the difference between the two code formatting styles (code-fences vs indented blocks) regarding syntax highlighting?
I have been using code fences to highlight my code in SO
```javascript
```
Recently I have noted that my code is being edited and the below syntax is being used
<!-- lang-js -->
I have seen ...
4
votes
0
answers
125
views
Why are tabs in the code replaced with spaces?
Why are tabs replaced by spaces in the output when I type them inside of code fences?
Here I used tabs:
int func()
{
somecode;
}
But you see spaces.
-36
votes
1
answer
183
views
Suggestions to improve Stack Overflow and GitHub
I'm new to programming and have been using stackOverflow and github only for the last 5 days.
I have a couple of observations.
Would it be worthwhile if, SO/gitHub adminstrators enforce strict code ...
-20
votes
2
answers
182
views
Code readability of questions
When a user is asking a question SO has many ways of making sure the question is at high quality, SO has many guides and rules to make a good question and they are doing the job well.
I would like to ...
2
votes
0
answers
76
views
In Firefox, the scroll bars can only be dragged a few pixels when a selection straddling the top of a code block and its preceding text is selected [closed]
Related - but not a duplicate: Please remove scrollbar-width: thin from code blocks AND fix the missing ends
In Firefox: if (at the very least) the last character before a code block and the first ...
-1
votes
1
answer
203
views
Prohibit low-rep users from posting links to images
No matter how much we discourage it, posters frequently write questions with all the code in an image that they link to. I personally don't think this should be a reason to close the questions -- if ...
30
votes
0
answers
342
views
Please remove scrollbar-width: thin from code blocks AND fix the missing ends
Horizontal scrolling of code blocks is a thing to say the least.
foo bar baz buzz foo bar baz buzz foo bar baz buzz foo bar baz buzz foo bar baz buzz foo bar baz buzz foo bar baz buzz foo bar baz ...
1
vote
0
answers
89
views
Bug: Interpreting C# code as incorrectly formatted code [duplicate]
When using the code format sometimes the color isn't correct.
For example, in this question the word CPerson Blue is blue instead of Black:
And the set is Blue, and get is Black:
This is a ...
5
votes
0
answers
127
views
Can we add a nudge to use a PowerShell validator when PowerShell code is detected?
For a while I have been contributing to Stack Overflow with PowerShell questions and answers. In here I am seeing a lot of questions with code examples that could be automatically resolved (or ...
21
votes
0
answers
128
views
Add codesandbox.io to the list of sites that prompt to put code in the question itself?
As far as I am aware, if someone asks a question and pastes a link to websites like JSFiddle, JSBin, or CodePen, they get prompted to put code in the question itself.
Lately I've been seeing links to ...
1
vote
0
answers
57
views
Why is code not highlighted and snippets not runnable after an edit? [duplicate]
When a post that contains code is edited and I click on the "An edit has been made to this post" link above it, I can see the edited post, but the code will not be highlighted unless I refresh the ...
3
votes
0
answers
102
views
Syntax is not getting highlighted/accepted even if I use (Ctr+K) or indent the code myself
I have tried everything from using '```python' to indenting myself. The code which I want to upload does get highlighted in grey when I use the above methods but the syntax doesn't get highlighted. ...
1
vote
2
answers
215
views
How production-ready should code in answers be?
In https://stackoverflow.com/a/56874892/1491895, @Dharman posted the following comment:
It is a very bad idea to use die(mysqli_error($conn)); in your code, because it could potentially leak ...
2
votes
1
answer
69
views
Code snippet not getting highlighted [duplicate]
I have a piece of code after a list in a question. It is not getting syntax highlighted, even if I use SO code block, or indent it myself.
If I move it before the list, it works as expected. Also, ...
5
votes
3
answers
220
views
Am I allowed to recommend different code in an answer from what's provided in the question?
During answering this question another answer was posted and when I studied it, I saw that the user has deleted some lines of code so the code may properly work. Are we allowed to change the given ...
27
votes
2
answers
772
views
Are backticks appropriate for emphasizing references to things that show up in code?
I've been following this "When should code formatting be used for non-code text?
" post for guidance on removing backticks when reviewing suggested edits as well as when forming my own questions and ...
11
votes
2
answers
160
views
How should I review answers with screenshots of code in Low Quality Posts?
This is related to Should I review questions with images of code as "looks ok" or "requires editing"?, but for Low Quality Posts, which I consider a different situation than Triage....
-7
votes
1
answer
119
views
Colorize code after adding ASP.NET Core code
Has it ever been considered to colorize the code in a post which is tagged with asp.net, asp.net-mvc, etc. like the tag c#?
(Sorry if this is posted earlier, but I couldn't find anything about this.)
40
votes
3
answers
1k
views
How will Article 13 (EU) impact content on the Stack Exchange network?
As you hopefully know, in a few weeks, EU Parliament will vote for new copyright laws.
These new laws/directives (especially its most controversial component, Article 13) (Julia Reda shared the ...
8
votes
1
answer
785
views
Best practice for using code snippets from Stack Overflow
Is there a best practice for reusing code snippets from Stack Overflow in production code?
Personally I always do something like this:
// Handling input that is not parseable as an integer.
// ...
2
votes
0
answers
174
views
Clarification on Stack Overflow code license [duplicate]
I have seen tons of posts on the license on the code used here on stackoverflow.com. A simple search brings tons of results but I still don't fully understand the license the code on this site is ...
17
votes
1
answer
499
views
How to use the regular code snippets in the 2018 Stack Overflow update
I am a little confused with the new update of Stack Overflow, particularly on using the regular JavaScript/CSS/HTML code snippets we used to have to write our questions. Now the new update made it ...
10
votes
3
answers
182
views
Do you need to change the language of variables to English when asking a question? [duplicate]
For instance, I am Dutch and most of the time is I use Dutch words to declare variables. for smaller lines of code it's easy to translate, but is it something you should always do?
Is the question ...
-10
votes
1
answer
120
views
Is there a reason why code formatting does not have any rules?
When I have a time, I really like to help people on Stack Overflow.
Questions I'm reading are mostly created by new users or others that did not ask much questions in a past. Those questions are ...