What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

Just a quick one. Consider the following code:

<?php echo "test"; ?>

If I write that just below here, improperly indented, it's removed from the output (source link):

Can we get some sort of warning for the new users before posting to remind them that this has been removed from the output and if it's source code it needs properly formatting? Something that fades in below the "How to Format" box might be cool.

Note

The following will not be displayed in the output:

    <?php echo "test"; ?>

If you are pasting source code, please follow the guidelines in the "How to Format" box above.

Case in point, which inspired me to request this, but I see it happen quite a lot with low rep users.

Of course, I think this will only apply to HTML and XML style markup, because other languages aren't sanitized AFAIK. It would catch a lot of PHP, XML, HTML and Javascript (between <script></script>) posted code though.

share|improve this question
    
@ccomet: thanks for the source link :-) –  Andy E Jun 22 '10 at 12:09
    
How would you identify code that should do this? anything tag-like? –  C. Ross Jun 22 '10 at 12:26
    
@C. Ross, realistically it would only apply to html and xml style markup where the code is sanitized from the output. Other code isn't really santized, AFAIK. When the user enters some text into the markdown box, the sanitizer removes any invalid "HTML" tags. When it does this, it could quite easily raise a flag to notify the user of the invalid markup. –  Andy E Jun 22 '10 at 12:32
    
@C.Ross The only code that is affected is anything resembling an HTML or XML tag that is not escaped or in a code block. The accepted HTML tags are converted into their actual HTML entities, while anything else is just stripped. –  Grace Note Jun 22 '10 at 12:34
1  
Is that extra complexity really necessary? It's already pretty easy to notice, and trivial to fix. –  C. Ross Jun 22 '10 at 12:55
1  
@C. Ross: The linked question already had 2 downvotes before I edited it. Would those downvotes would have still been given if the user had correctly formatted the code in the first place? Maybe, but I doubt it. I also don't think it's much "extra complexity", you're already sanitizing the post, all that's needed is raising a flag when doing so. –  Andy E Jun 22 '10 at 13:16
    
Expecting programmers to learn the (very, very simple) rules for formatting text on SO doesn't seem like too much to ask. This would make the most sense for non-programming SE sites... Where no one should be posting code anyway. In my experience, it's the users lazily pasting in code without bothering to see if it displays who also need the most help learning how to ask a proper question anyway, so while you're in there editing why not finish the job (as George did in your example)? –  Shog9 Dec 15 '10 at 18:08
add comment

2 Answers

Great idea.

No, it shouldn't be implemented.

Since there are a large number of people that can edit posts, we should keep what works and crowdsource that out to the community instead of an automated system that may introduce bugs or slow performance.

share|improve this answer
    
+1 for the "Great idea! But no." –  Gnoupi Jun 22 '10 at 12:39
add comment

Be careful, because you've just created a perverse incentive to type code in as plain text.

In other words, if typing

<?php echo "test"; ?>

worked, that's all people would do -- they wouldn't bother learning how to format code correctly!

share|improve this answer
    
I'm not asking that SE works around it, just that it tells the user that it won't work and how to fix it. We're helping them learn :-) I wonder why this question is receiving so much attention today. –  Andy E Dec 15 '10 at 18:12
1  
@Andy because you bumped it :) –  balpha Dec 15 '10 at 19:22
    
@balhpa: lol completely forgot I'd edited it - facepalm –  Andy E Dec 15 '10 at 19:48
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .