For questions about making code appear correctly in questions, answers and comments.
1
vote
2answers
81 views
How can I fix the VB comments and their formatting in questions that are tagged c#? [closed]
As soon as a VB comment is in a code sample, the rest of the code formatting is messed up until the next comment (if there is another one).
Should we add a policy to escape comments with ' so the ...
-4
votes
1answer
55 views
Starting a new line in SO topic comments [duplicate]
A new line can be started in a question text box by double enter or double space. But... how to start a new text line in Comments to any SO topic?
And, how to start a new line in Code section of ...
0
votes
1answer
87 views
Should questions be edited to remove error-checking statements that dilute the code?
In C one should rigorously perform null-checks, however doing so obfuscates the rest of the code making it more difficult to review. Is it okay to remove such statements from an original post solely ...
2
votes
0answers
68 views
Questions with pictures of code [duplicate]
I am sure many of you have seen several questions where the OP posts a picture of their code instead of copy and pasting. Is it possible to have a small warning or such present when the user is ...
18
votes
2answers
345 views
No spacing between code spans in list items
While editing profile, this is how the preview shows list items containing code spans:
But this is the actual result after editing profile:
Expected result: There should be spacing ...
-4
votes
1answer
57 views
web.xml formatting in SO questions shows grayed out or commented out code though its not commented out
Refer this image in which had a /messagebroker/* as required and formatting misunderstood it as commented out code.
Please correct me if I am missing anything.
5
votes
1answer
178 views
Automatically indent code the correct amount under numbered lists [duplicate]
Code does not show correctly under a numbered list:
I have found some questions about this, like
Code block bug when following numbered list?, no one says that is a bug, and has a tag status-...
3
votes
0answers
218 views
Is it possible to get more advanced Ecmascript syntax highlighting for code snippets?
I've done some searches and this doesn't appear to be an option as far as I can tell.
I know about <!-- language: lang-js --> and it works great, but it doesn't do a great job with some more ...
-2
votes
1answer
78 views
Toggle Code block [duplicate]
I feel I have written a very long code block in a question which I'd like to be able to toggle - is there a possibility to toggle these longer blocks (I do not mean to run the snippet inside!).
52
votes
1answer
805 views
New Stack Snippets design requires more horizontal scrolling through code
I can't see the new Stack Snippet layout as an improvement. The window is now narrower, with wasted space around it, making it harder to format code to not require horizontal scrolling, especially if ...
-4
votes
1answer
51 views
Convention to add code while answering in middle of text
While answering the questions I need to add code in middle of the text, but after selecting the code in editor still it doesn't reflect as a code. It suggests me to give spaces.
So suggest what ...
3
votes
0answers
58 views
Code blocks in blockquotes render incorrectly (Preview window & answer) [duplicate]
I was just writing this answer when I noticed the code block in the blockquote I put in there didn't render properly.
Screenshot:
There appears to be some corrupted rules in the style sheets:
...
0
votes
1answer
50 views
External code snippet How-To?
I'm having a lot of trouble with code snippets. I like codepen.io, but here's me trying to paste the 'embed' code:
What I paste into the editor
<p data-height="265" data-theme-id="0" data-slug-...
1
vote
0answers
40 views
Why are some code snippets not formatted properly? [duplicate]
Sometimes my code snippets are not formatted properly. Why?
Here's a working example:
Here's the source code:
Here's a nonworking example
And its source:
-5
votes
1answer
79 views
Can line numbers for code and copy code to clipboard be appropriate in Stack Overflow questions? [duplicate]
Sometimes developers show the stack trace with code. For example:
Traceback (most recent call last):
File "C:/Users/Tucker Siegel/Desktop/Machines/Test.py", line 156, in <module>
...
1
vote
1answer
39 views
Should exceptions resulting from code be inside code snippets?
I've always used block quotes to display the resulting exception from code I need help with or something I didn't understand. But for some reason people always seem to edit them and put the exception ...
-9
votes
1answer
77 views
How to paste and mark it as code very fast
I can't paste code without having to scroll up again to mark it as code. Isn't there three ways so that I can paste without going up to the beginning? There's quotes, marking it and isn't there some ...
0
votes
1answer
43 views
Indented line of code doesn't show as block of code in Chrome
Regarding this answer when I view it in Chrome Version 49.0.2623.112 m (64-bit) on Windows 7 SP1 64-bit. The answer has only 1 line of indented line of code (with more than 4 spaces), when viewing the ...
47
votes
1answer
451 views
Code block inside quote block formatting is broken on meta
After seeing How to include code inside a quotation? and its associated answer, I saw that a code block inside a quote block formatting is broken on meta. If we use the example from the answer on meta ...
15
votes
1answer
633 views
How to include code inside a quotation? [duplicate]
This is so bloody irritating - I finally just managed to format my answer, so code appears inside a quotation using <pre>, and I get "Your post appears to contain code that is not properly ...
2
votes
1answer
56 views
Stack Snippet dialog can format code. Does it work for more than JS? [closed]
So I know that Stack Snippets can only run HTML/CSS/JS. But they have a neat formatting ability. You press the "tidy" button and it's like magic.
JS is part of the C style syntax family, so JS ...
0
votes
0answers
78 views
Underline links inside code blocks
Sometimes I use links inside code blocks, e.g.
interface HTMLCollection {
readonly attribute unsigned long length;
getter Element? item(unsigned long index);
getter Element? namedItem(DOMString ...
1
vote
0answers
106 views
Unable to edit an answer
I am trying to edit an answer, this is current revision.
Your post appears to contain code that is not
properly formatted as code. Please indent all code by 4 spaces using
the code toolbar ...
22
votes
0answers
344 views
Grey background doesn't appear for code in deleted answers
The grey background for code seems to have disappeared for deleted answers. For example, this deleted answer looks like this:
This happens on meta as well
Bug?
I'm using the latest version of ...
0
votes
0answers
45 views
How do you separate adjacent code blocks? [duplicate]
I was just looking at this question: changing the innertext of a nested node and assigning it the value of the first sibling of the parent node in C#.
The original poster has put an XML code block ...
1
vote
1answer
148 views
Why isn't this code being formatted properly?
So I made a revision to a poorly formatted post, which had most of its words in a code block. I didn't realize it when I was editing, but somehow, four spaces is not creating code blocks. (One code ...
1
vote
0answers
51 views
How to interleave code with console output [closed]
I would like advice on good techniques to format questions that contain both code and related console output
I'm interested in the following aspects:
Each output clearly related to its code.
Easy ...
2
votes
1answer
81 views
How to format this kind of code?
I came across a question that was weirdly formatted with ``` to indent code. As the output was unsexy, it tried to edit it with no luck, here's the question:
I have a Scala regex which does match ...
70
votes
3answers
1k views
Don't wrap code at hyphen
It is common when writing Haskell questions to write language extensions beginning with - as code. The editor seems to think this is a hyphenated word that it can split between two lines, even though ...
18
votes
1answer
252 views
Inconsistency of indentation of tabs between markup editor / code samples and Stack Snippets
Many real life projects contain code that mixes up tab-based indentation with space-based indentation.
In different editors, tabs don't always correspond with the same number of spaces. For example, ...
2
votes
0answers
30 views
Adding a link to a code with brackets escapes it automatically
Recently while formatting a post, I noticed that the brackets in the code (formatted by using `code`) are getting escaped automatically, when we give a link to it.
Take this as a sample callMe(\[\]). ...
0
votes
0answers
26 views
Why sometimes source formatting does not work? [duplicate]
Here is an example. Code indented 4 spaces - not being properly formatted (link to edit, to verify that it is indented 4 spaces).
What's the reason?
-9
votes
1answer
84 views
Automatic trimming spaces from beginning of lines of code
When you copy your code and want to post it on SO, it's usually indented relative to outer brackets/tags. When you post it and click the Code Sample, it leaves it like it is and you have to trim the ...
48
votes
1answer
802 views
How do I remove excess indentation on my code blocks?
This happens to me a lot on Stack Overflow: I paste in some code, but it is indented to the right far too much. This requires cumbersome horizontal scrolling to view all of the code, and oftentimes ...
9
votes
3answers
611 views
Backticks in tags
I was going through the review queue and came across a change to a tag wiki excerpt that consisted of removing the backticks around certain words that were appropriate for code blocks. After looking ...
1
vote
0answers
90 views
Unable to post my question because it is not properly formatted
I've seen this question asked and answered various times, but I can't solve it with the given information. I have code that displays just as I want it in the preview. But more than an hour of trying ...
2
votes
1answer
64 views
Is the code formatting for Perl broken?
Why does the Perl code formatting seem to be so broken?
Take this question for example: after the line $value //= qr{}; we can see that the code formatting is completely messed up until the user ...
6
votes
1answer
245 views
How do I paste code into the code snippet? [duplicate]
Whenever I click the { } button, then paste my code in, I sometimes get just one line of code, but I never get my full code snippet enclosed in the proper format.
Is this because my code is indented? ...
1
vote
0answers
57 views
What is the preferred way to format a long one-liner in an answer?
When I am at the shell prompt, sometimes I write (unreasonably) long one-liners. The same happens when I answer bash questions here. Obviously, untils and fors and ifs get their own lines, but what ...
-11
votes
1answer
64 views
Make code blocks containing URLs automatically <!— language: lang-none -->
As I frequent the java tag, I see this quite often:
http://www.example.net/app/showthread.php?tid=38798742343
As you can see, everything behind the // gets displayed in a grey color because Stack ...
5
votes
0answers
108 views
Formatting convention for “this code is in this file” [duplicate]
I occasionally come across questions that refer to several different source code files. In some questions, it's pretty clear which code belongs to which file, but not always. I often want to edit ...
3
votes
1answer
131 views
What is the correct way to share R data on StackOverflow?
I see a lot of r questions where the OP refers to a specific data.frame or other data structure. Often, they include an image of the data.frame. This has several drawbacks, including not being able to ...
0
votes
1answer
54 views
Is it possible to add markup tags to a block quote?
Often people just include screenshots to show their errors but today I tried to edit one of those posts, and the error message contained List<T>. For the sake of simplicity let's say
Error: ...
-16
votes
1answer
181 views
Stack Overflow complains that my code is improperly formatted
I am trying to post a question about R, but Stack Overflow blocks the post with an error message about the code being improperly formatted. I have used Ctrl-k on the code and it is all highlighted in ...
10
votes
1answer
95 views
Code in comments not properly rendered [duplicate]
I typed ` | "a"` into a comment, but it didn't render as code. Instead, it just appears as regular text. See the comments below for examples.
-14
votes
2answers
104 views
Initial lines of code block are not formatted, cannot submit post
I cannot get my question accepted, because when I paste a code block, the first lines (import statements, class def.) are omitted from the code block, as is the final }. Also, weirdly. the * is ...
0
votes
0answers
38 views
Pasting multi-line code block sometimes fragments the code
I was trying to answer a SO question that involved some VBA. The question had a code block, which I copied to my VBA editor (which resulted in some non-indented lines, made some fixes, then put it ...
25
votes
1answer
474 views
Single-line code block scrolling looks very bad on OS X! [duplicate]
When I scroll horizontally through a single line code block on my MacBook, it looks like this:
This makes it very difficult to see what the code is, especially at the places where the scroll bar ...
1
vote
1answer
30 views
Code formatting is not working [duplicate]
In this answer when I am trying to format the code (the first code block after 'Default Params', in which }); is not formatted) is not working as expected.
2
votes
1answer
67 views
SO editor not working
Suddenly editor stopped highlighting the Keywords in SQL. For example SELECT, FROM, INNER JOIN etc should be highlighted in blue color but it's not happening. This is my query. Here is my answer
...