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!.
137
questions
11
votes
0
answers
109
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
161
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....
2
votes
1
answer
206
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
266
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 ...
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
520
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 ...
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 ...
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 ...
-9
votes
2
answers
205
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 ...
1
vote
0
answers
142
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
408
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-...
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 ...
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
88
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
409
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
608
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
75
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, ...
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 ...
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 ...
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 ...
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 ...
-6
votes
3
answers
403
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 ...
2
votes
1
answer
314
views
Explaining/Describing the code below or above the code? [closed]
Is there a preferred style on this site, where to put explanations of the code one posted?
Should it be done like this:
Some explanation above
if (x != y)
//do something
or like this:
if (...
-8
votes
1
answer
107
views
Code coloring in comment is not working
I just observed that when I post a comment containing a piece of code, the code is not colored as it is in answers and questions. Here is a screenshot:
In the above screenshot, I just posted a ...
3
votes
0
answers
133
views
Acceptable question with too low text-to-body ratio
Not long ago I gained the privilege to review queues and I try to help the community a little by handling issues in the queues.
My issue is with questions with low text-to-body ratio. Often askers ...
0
votes
0
answers
31
views
When to edit code/links into snippet? [duplicate]
Being that I'm relatively new in my education on front-end development, I've come across a lot of older, basic questions that I use to help myself along. Oftentimes, if there is plain code there, I ...
14
votes
2
answers
626
views
How to provide additional code to comment an answer?
I asked a question and provided corresponding code inside my question using the tools Stack Overflow provides. Now, someone answered, but I feel like I need to provide additional code specific to his ...
8
votes
1
answer
313
views
How to fix an answer with a link to plnkr.co? [duplicate]
On Jul 3 '14, Shog9 forbid plnkr.co snippet links without code on Stack Overflow.
Regarding posts left without code but with plnkr.co links: for questions, I may vote to close as "No MCVE in the ...
13
votes
3
answers
316
views
Should code samples be tailored for readability or efficiency?
Posing this question resulting from a comment debate on my answer here: send gmail using powershell - Current suggestions on S.O. are NOT working
When providing code samples on Stack Overflow, should ...
1
vote
1
answer
116
views
Should we comment our code when answering questions?
I am torn between two worlds on this one. When answering a question, I like to post clean, minimal code. However, sometimes that code may not be entirely clear to the original asker and it can be ...