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

I noticed that my original tab characters in code snippet in Edit text box will be converted to white spaces when they are viewed on the rendered HTML. Ones who want to try my code usually copy the code from the rendered HTML. But for some special case where the tabs are valuable things, the output they will get will be totally different from mine. Code indentation gets lost in Beamer is the non-trivial example where changing tabs to spaces will make different result.

We can avoid this issue if they copy my code by entering the edit mode first, removing the code mark down, copying it and pasting it to their editor. But non-registered users cannot enter the edit mode.

share|improve this question
    
@Hans: Why did you delete your comment? In response to your deleted comment: I am not talking about the efficiency storage of using tabs and cost to implement this. :-) –  xport Jul 16 '11 at 21:47
3  
The Real World is a slight departure from the road you are traveling. It is on the left. –  Uphill Luge Jul 16 '11 at 21:48
1  
Would be handy for questions about the whitespace programming language. –  rightføld Jul 16 '11 at 22:30

2 Answers 2

It is difficult. You need to make everybody agree on the amount of horizontal space taken by a tab. Which is a convention, ranging between 2 and 8 spaces. With a few oddballs that think that 1 or 9 is on the right of that road. The fact that nobody agrees, or is ever capable of agreeing, is your nemesis.

Markup does 4.

share|improve this answer
    
How about providing a copy to clipboard button with JavaScript logic to remove SE/SO code snippet mark down first and copy the original code snippet as is (=preserving the original markup) to the clipboard? :-) –  xport Jul 16 '11 at 22:30
    
@xport: this has been suggested, but copy-to-clipboard is a PitA in browser script. –  Shog9 Jul 16 '11 at 22:36
    
@Hans: Does everybody agree with every CSS settings implemented in SE/SO? I think the CSS team will adjust the setting properly as they do for other settings. –  xport Jul 16 '11 at 22:46

A workaround is that you can also link to your code on pastebin.com.   Pastebin will preserve the original tabs for you.

Important: This does not mean use pastebin instead of code!

Use pastebin to preserve the tabs (if you really must), in addition to including the code with the question.

share|improve this answer
1  
One vote against pastebin links in SO questions. It encourages long, non-focused code samples. –  Michael Petrotta Jul 16 '11 at 22:54
4  
Pastebin links rot more quickly that you'd believe which often leads to questions being closed because no-one can see the original code. –  Kev Jul 16 '11 at 23:00
1  
This is not pastebin instead of code!! It's pastebin to preserve the tabs (if you really must), in addition to the code that should still be included with the question. –  Awesome Poodles Jul 16 '11 at 23:17

You must log in to answer this question.

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