Questions tagged [code-formatting]
For posts about making code appear correctly in questions, answers and their comments.
461
questions
4
votes
0
answers
128
views
I don't post code, but the editor requires me to format as code
Question in question: The Facebook app I create doesn't present in my profile setting. How to find User ID for Facebook App ID?
While I'm not sure which part the checker thinks it as code, I ...
2
votes
0
answers
74
views
Code block display bug? [duplicate]
I noticed that this answer used triple backticks in the markdown, but the rendered output looks strange to me. Is there a bug somewhere?
2
votes
0
answers
75
views
What kind of code format should I use for errors? [duplicate]
I was scrolling through Stack Overflow questions when I saw this one: Rscript Path Problem for exec() implementation R code in php
It's a beautifully structured question, except I find the way the ...
19
votes
3
answers
1k
views
Is a markup change enough improvement to be accepted as an edit?
Referring to the following suggested edit in the review queue: https://stackoverflow.com/review/suggested-edits/28302046
In case the suggested edit in question isn't accessible any longer, here it is ...
-8
votes
1
answer
208
views
Is there a way to write console-like not selectable text?
I constantly ask this to myself when reading/writing Python related questions or answers, so I'll use the Python console as example, but I'm pretty sure it can be extended to other contexts.
See for ...
4
votes
0
answers
82
views
How is table with code formatted illegally? [duplicate]
Could someone please for the love of G tell me why this table is not formatted correctly?!!!!
Base (base)
Exponent (exp)
Math.pow(base, exp)
numeral(n).format('0[.]00e+0')
logFormatter(n, base)
10
-...
3
votes
0
answers
62
views
Code formatting in Scala is wrong with multiple line string [duplicate]
I am asking this question after tackling this question:
How to test akka-http route to handle exception?
There is a lot of code there, bur as you can see the formatting is not correct for the first ...
57
votes
6
answers
1k
views
A way to reduce the number of questions with only images?
The problem:
This is something that I particularly see a lot in the pandas tag. People will ask questions that look something like the following:
I have the following dataframe <link to imgur ...
5
votes
0
answers
100
views
Preview Doesn't Match Live View
This question (Fatal error when try add snippets code on functions.php Wordpress) had HTML in it that caused the preview to display subtly different (after Complemento) than the actual question.
...
7
votes
0
answers
68
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 ...
3
votes
0
answers
48
views
Long lines in code break layout of revisions page [duplicate]
This first revision of a question has a very long line in a code section (no linebreaks). Instead of showing horizontal scrollbars, the preview of the post content does overflow the revisions page. ...
3
votes
0
answers
181
views
Bug in JavaScript code colors [duplicate]
The following JavaScript code:
let hsv2hsl = (h,s,v,l=v-v*s/2, m=Math.min(l,1-l)) => [h,m?(v-l)/m:0,l];
colors are wrong (starting from /2 which is interpreted as comment):
Light mode:
Dark mode:
...
8
votes
0
answers
102
views
Edit shows expected code with a different format than what it really is
I'm using Google Chrome on Android 10 - Samsung Galaxy A30s.
When looking at this question
We can see the first code block has a specific indentation. Then, when clicking to edit
The expected result ...
7
votes
1
answer
170
views
Literal tab in code block renders as four spaces
I think this used to work correctly before because I have memories of testing this when responding to makefile questions before, where proper tabs are crucial. (That would have been before the switch ...
6
votes
0
answers
78
views
The code editor is italicizing some code blocks [duplicate]
Example here:
I think it might have something to do with the arrow notation, since the italicized text didn't appear until I put that in.
6
votes
0
answers
134
views
Stack Overflow rejecting well-formatted code in question
Stack Overflow is rejecting a post that I am trying to create regarding Python. It complains that my post has improper code formatting, for reasons that I don't understand, even though the preview ...
10
votes
0
answers
116
views
Code links not distinguished on iPhone
Links within inline code (backticks) are not rendered in blue nor distinguished any other way from regular text on iPhone (tested on iPhone SE 2020, iOS 14.0.1).
Below is a screenshot for this post:
...
6
votes
0
answers
156
views
Deleted code block rendering problem on recent update of Chrome
Browser bug, or site bug?
Chrome just recently updated (to version 85.0.4183.121). After the update, code blocks found in deleted posts are rendered badly:
Interestingly, if you select the text, it ...
27
votes
5
answers
1k
views
When should we use code, quotes and bold blocks?
I've seen countless posts where using Markdown blocks has been "wacky".
Many of these posts used citation blocks for error logs, for example, while others used bold or italics. Some also use ...
2
votes
2
answers
1k
views
How can I type backticks on my Samsung smartphone, which are needed for inline code snippets?
I'm a regular writer here on the site, and I'm more and more working with my smartphone (instead of my computer), but I have an issue: backticks only seem to be usable as accent signs (like "à&...
8
votes
2
answers
183
views
How do I put a code block in a comment that starts and ends with spaces?
I was writing a reply in a comment just recently and I realized I could not turn something into a code block if it started and ended with a space. The particular comment in question is here. After a ...
107
votes
3
answers
17k
views
How does the highlight.js change affect Stack Overflow specifically?
Update 2020-09-24
This is now live network-wide (including Stack Overflow).
Update
This is now live on Meta Stack Exchange and Meta Stack Overflow. Any bugs and feedback can be posted on the main post ...
-7
votes
2
answers
221
views
OP's question was erroneously edited. The moderators want to keep erroneous question as it looks 'pretty' and readable
I have a question about my Stack Overflow post: Truncate column names in SELECT (MySQL client)
The OP for a MySQL query (Truncate column names in SELECT (MySQL client)) had a problem with the ...
6
votes
0
answers
107
views
This message keeps me from posting "Your post appears to contain code that is not properly formatted as code."
I am trying to post a question on StackOverflow but it seems like this message "Your post appears to contain code that is not properly formatted as code" keeps me from posting. I have ...
4
votes
0
answers
121
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.
7
votes
1
answer
101
views
CommonMark doesn't generate correct HTML markup
I have tried editing this post https://stackoverflow.com/a/62887975/1839439
This is what I see in the preview:
This is what I get after saving:
This is the markdown used:
You can try this if it ...
1
vote
0
answers
39
views
Clojure code highlight is broken [duplicate]
I am wondering why nobody has reported this issue before.
It looks like the highlighter incorrectly picks symbols at the end of words.
This is a picture from this question:
Stuck with type hints in ...
9
votes
2
answers
252
views
Why does syntax highlighting only work when previewing an edit to this old answer?
I made an edit to this old answer of mine. Among other changes, I converted from indentation-defined code blocks to code fence-defined code blocks. Despite the question being tagged as C#, I ...
3
votes
0
answers
86
views
Code block overflows on Google Chrome [duplicate]
In rare circumstances a code block overflows the container in Google Chrome. It works fine in Firefox.
Example: php 5.3/mysql: why doesn't apache see mysql?
-4
votes
1
answer
199
views
How to put bold text inside a code fence? [duplicate]
I want to make a code fence, and in that code fence, I want bold text.
I have tried:
<strong>bold</strong>
**Bold**
But they don't work.
Here is what I want to happen:
import tkinter as ...
5
votes
1
answer
97
views
Just how short does a code block have to be to avoid horizontal scroll?
Today I edited an answer that interested me to try to get rid of the horizontal scroll.
You can see the final results here:
https://stackoverflow.com/a/59217352/5486
And the previous revision here:
...
3
votes
0
answers
66
views
Why is not all the code formatted as code in my comment? [duplicate]
I've added a comment to this question, but as you can see there's something wrong in the formatting: I've used backticks on two places, and it works on the first, but not on the second place, as you ...
4
votes
1
answer
285
views
How to handle questions with code as images [duplicate]
When someone (typically a first-time poster) posts a question that contains code presented as an image, we're supposed to encourage them to edit the question and repost as plain text, for all the ...
6
votes
0
answers
85
views
Preview does not render code blocks as code if they contain a paragraph separator (unicode decimal 8233, hex 2029)
If you edit this question, you'll see the problem.
Here's a code block with a paragraph separator char between "foo" and "bar":
var str = "foo
bar"
var also = "other lines"
The above line renders ...
0
votes
0
answers
72
views
SO couldn't format the following Lisp code properly [duplicate]
The following code is copied from https://github.com/emacs-mirror/emacs/blob/master/lisp/simple.el#L1347-L1358. When I copy it into the body of this question, the indentation goes wrong after line ...
5
votes
1
answer
313
views
How can we add a tab to every line?
So, many people mess up code fences in their questions. One of the most common errors is that one tab is missing at the beginning of every line. Example:
public class ExampleClass{
private void ...
6
votes
1
answer
136
views
Automatically resize code blocks to fit the horizontal scroll bar within the screen
Consider a fairly large block of code. For example, this question. On my 1366x768 screen laptop, this is what I see:
If I have to scroll horizontally in the code block, I have to first scroll down, ...
5
votes
1
answer
323
views
How to properly format terraform (HCL) code
There's insufficient documentation on which code language identifier to use for the terraform language.
The expected values (tf, hcl, or terraform) do not work.
Is this supported, and if so, what is ...
5
votes
0
answers
66
views
Markdown with fenced code blocks within lists has inconsistent previewed/final renderings
About the bug
This is a bug whose effects you can see in the revision history of this answer. Specifically, it’s about the edit that created Revision 15 (click “side-by-side markdown” to see that ...
-20
votes
2
answers
175
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 ...
6
votes
0
answers
62
views
Run-on string when formatter believes a string ending back tick is escaped
I came across this answer's code snippet. In Golang, strings enclosed in backticks are taken as a raw string. It doesn't parse for escape sequences. The code formatter erroneously colors the rest of ...
9
votes
0
answers
165
views
Formatted code colors have changed, for the worse
Why have formatted code colors changed within the past 2 days?
Here is an example with the old colors on the left, new on the right
(Taken from this question which was asked 2 days ago, and I ...
4
votes
0
answers
97
views
Link to line in code snippet
When sharing code from GitHub with people, I can get a link to the exact line, which helps with clarity when I'm bringing attention to something specific.
I would like to do the same when linking ...
5
votes
0
answers
114
views
Are edits that purely reformat code, based on preference, good edits?
Start note: This question is very similar to a question that was flagged as similar. Are purely cosmetic edits to original code frowned-upon, even if they accompany high-value non-code revisions? The ...
5
votes
0
answers
151
views
Which part of my previous post "is NOT properly formatted as code" on Stack Overflow?
Could anyone specify which part was wrong with my description in my previous post?
I've just asked a question on Stack Overflow here. In the process, I couldn't post my question because of the ...
-21
votes
2
answers
231
views
Why are people using 4 space-indent to post code?
I'm baffled why people are using 4 space-indent when posting code. It tends to screw up indentation on posts. It also does not have language-specific highlighting.
What I always use is the triple `. (...
2
votes
0
answers
197
views
Weird line breaks in code in mobile view on IOS
See e.g. this recent answer of mine. The mobile view shows a line break in the middle of the keyword next even though there is a longer line just below it which isn't wrapped at all.
Screen shot:
...
1
vote
0
answers
88
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 ...
34
votes
0
answers
198
views
Users frequently start code blocks on the same line as the triple backticks
Every day I fix up lots of questions where the poster has written their code blocks like this:
```<html>
blah
blah
</html>```
When they do this, the first line of the code is not ...
5
votes
0
answers
126
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 ...