Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

142

Unfortunately, this is an ambiguity in the Markdown specification. This markdown source: 42. list item more text can mean two things. One of them is the one you're expecting: more text is following a blank line and indented by four spaces, making it a top-level (i.e. not part of the list) code block. The second possible meaning is this: List items ...


18

Nobody needs to throw ten tons of code into a question. Nobody. Plus, tl;dr syndrome guarantees that the more crap you throw in a question the more likely it is you won't get an answer. Hell, I think the max question length should be dropped by 3/4. I've heard that skill in asking a question is more important than length. Or was it column width? ...


16

In my opinion, this is a great idea (if it is implemented as optional). Maybe add to the current formatting directives; something like: <!-- language:lang-c ln:true --> or as a new indicator: <!-- language:lang-c --> <!-- ln:true/yes/false/no/etc... -->


16

On questions, it really should only be done to increase readability, like spacing and tabs. I edited on the other day just for that, and still ended up deleting a errant apostrophe that may have been the OP's problem, so you have to be careful. On answers, I may improve something really obvious that is either a mistake, or just looked like it was ...


15

the links are to code that the asker him/her-self created, and chose not to include in the body of the post. The argument against this practice is that site should be self-contained. Paste bins and picture dumps go down. SO shouldn't be effected by this. Use the features built into the software (built-in image upload and code formatting/hilighting). ...


15

As lunboks notes you can search code blocks with the code: search term. e.g. code:"new" So you should be able to use user:me code:"new" to find what you're looking for. It doesn't appear to search bodies or titles, but I couldn't find any documentation for it.


15

I reproduced that onTwitterInit : function () { if (window.twttr) { var that = this; window.twttr.anywhere(function (T) {
 doesn't get rendered properly in the preview: The culprit is a Unicode character (code 8232) following the { on the last line. If you remove it, the rendering problems disappears. U+2028 is the Unicode ...


14

This is not recommended. Stack Overflow is not your personal debugging service. Ideally you should narrow your problem down to a simple, isolated section of code. Something we could try for ourselves without having to wade through your entire project. This also means that if you have a large project, you should not include all your sources within your post. ...


13

The workaround which is to add 8 spaces instead of simply 4 is actually written in the markdown editing help: (...) (...) (...) Preformatted text in a list item: Skip a line and indent eight spaces. That's four spaces for the list and four to trigger the code block.


12

The merits or demerits of a code-only answer is a different matter. But constraining answers to pseudocode would detract from a large majority of answers and add little or no value. Most importantly (in my opinion), the ability to get a specific answer to a specific question would be lost. Sometimes even experienced developers want to be able to cut-and-...


12

When I was examining licenses for some content that I create, I came across the Free Software Foundation's "How to Choose a License for Your Own Work" page. Of course, their first recommendation is the GNU General Public License, a strong copyleft license. However, they do have exceptions to this: For small programs (they define small as <300 lines), ...


11

I think this will be impossible to ever handle automatically: There are many, many questions that make sense without any sample code. I think manually commenting where it is really needed remains the way to go.


10

Select all the code. Press Ctrl+K. Alternatively, click the bracket sign (the 5th in the toolbar). Comments only support mini-Markdown, i.e. asterisked or underscored bold/italic, links, and inline code (surround with backticks). They're not intended to be used for anything heavy, just brief notes. Click help next to the comment box for more info, or see ...


9

You can't attach a file here, but you can post your code in the question itself. Post the code in the body of your question, select it with your mouse, then click the { } button above the edit window to format it as a code block.


9

It is usually best to explain what is going wrong with the OP's approach and why. Additionally, if there is an easy way to correct the problem, you should demonstrate it. If you can think of a better approach, this should be posted in addition to a diagnosis of the original problem. An example would be a user making a mistake while using the wrong tool ...


9

It's unnecessary and rather contradictory to the fact that it's desirable to submit short self contained compilable examples. See www.sscce.org. An editor that facilitates uploading large amounts of code will cause the upload of large amounts of code. We don't want that. The markdown format works well enough. It's also nice to be able to see the question ...


8

As a rule, I think we discourage large amounts of code for several reasons.. It's off-putting to a searcher to see pages and pages of code before they get to any answers SO is for general, reusable questions and solutions. If explaining your problem requires 2000 lines of code it's probably too specific to be of use to someone else SO is not a free ...


8

If line numbering is really so problematic (IMO not), what about debugger-like break points? Not a complete solution, but at least very "visual". <!-- language: lang-java --> <!-- break color:red --> @Override public int add(int num1, int num2) { <!-- break:"here" color:yellow --> return num1 + num2; } And the ...


8

If you've got a large amount of code you should consider trying to reduce it to the barest minimum that repeats the problem. You are more likely to find people will be prepared to read a short 20 line snippet of code and help you than some class file that 500+ lines long.


8

Well, your original question referenced specific code that wasn't working as expected. You jumped to the conclusion that it was about using Java vs Mathematica syntax. What makes you so sure that is even the problem? It's unclear from the question how your problem even relates to the question you're asking as an end result. Have you tried using the other one ...


8

Those 2 lines are public domain because they don't meet the threshold of originality. Copying them is not fair use: it's entirely free as far as copyright goes. This is valid in all countries. However it's possible even for a single line of code to be original and hence copyrighted. The distinction is usually hard to make and varies per jurisdiction, which ...


8

Besides that just typo questions should be flagged rather than answered, you can always (almost?) use (language specific) comments to highlight your code changes: Ah, just a typo. You meant: <html><!-- <<<<<<<<< <htwl> is mistyped --> <body> document </body> </html> Not ...


7

I think it depends on who you are answering to. If you can see that it is a total beginner who needs things to be explain step by step, then rewrite his code, showing and explaining to him where things can be improved. If you have to deal with an experienced user (who is just probably too tired or something. I guess you can have an hint on his skills if ...


7

Short answer: No. If you are unable to fit your problem into the question itself, it probably fails either the "specific" or "practical" test for questions. It also fails the test of "reasonably scoped".


7

Stack Overflow is better suited for practical programming questions about specific issues. Try CodeReview.StackExchange.com for code reviews. Be sure to read their FAQ though. For one, I think it's preferred or even required to put your code (the relevant bits) in the question to make it stand on itself, as well as to prevent link rot. To quote the relevant ...


7

Perhaps we should consider improvements to the posting interface as well: More explicit ways to say "This is code, and thus covered under the code license." Just using code formatting as a determination seems too likely to include content that shouldn't be included, and leave out content that should. A way to (easily) say "this is code, and I'm releasing it ...


7

I am in favor of this, SmartyPants-like formatting is an annoyance. If people want to write typographically correct characters they should use an input method that supports that on their systems. I use the X11 compose key, on Windows there is a nice program called WinCompose and alternatives exist on all platforms. (For example on Android I use ...


7

You can just go to the revisions list (by clicking on the 'edited <timestamp>' link below the post, above the editor's user card), scroll down to the previous revision, and click 'rollback'. That will bring the post back to that state. You've already posted a comment notifying the user of this problem, so they are probably aware and might reply ("sorry, ...


6

I just found a solution for this. If you put a </ul> after the listed item. The issue will be fixed.


Only top voted, non community-wiki answers of a minimum length are eligible