Consider the following code block:

a   b

What I typed in markdown was the sequence of bytes 0x61 0x09 0x62 (pretend Unicode doesn't exist). The middle character is a tab.

But as you can see in the rendered output, the tab is converted into a sequence of 0x20 spaces. This is problematic for languages with significant whitespace. No, I'm not talking about Python (where tabs and spaces are both usable for indentation), but neither am I talking about silly esolangs like Whitespace.

I'm talking about MUMPS, a real language that people use (yes, really!), in which tabs are a syntactically-significant construct. Consider the following MUMPS code:

timesTwo(x) set y=x*2
    write y

In order for this to be syntactically correct, lines 2 and 3 must start with a \t, and the set on line 1 must be preceded by a \t. As is, you cannot copy-paste the code block above from this post into a MUMPS routine and have it work, since the tabs are converted to spaces when the markdown is rendered to HTML for display.

Now, I'm willing to believe that there may be benefits to users of other, less-awful languages that outweigh the issues this causes with MUMPS, but I don't know what they are. Why do we have this auto-tabs-to-spaces conversion thing going on?

(Context: I was trying to figure out why I was having issues with this PPCG post.)

  • 1
    You can bypass this by using <pre> tags, e.g. <pre>a b</pre> will preserve the tab. (not in comments though) – Shadow The Curly Braced Wizard Sep 29 '15 at 22:29
  • The big question is, then, how much awful Python code with both tabs and spaces is posted network wide versus the amount of MUMPS code that has its poor, tabs removed... Then again, I'd be willing to bet the average quality of a MUMPS question across the network is higher than Python... – ben is uǝq backwards Sep 29 '15 at 22:30
  • @ShadowWizard You sure about that? I switched to pre tags here: codegolf.stackexchange.com/a/59086 (first code block). Doesn't seem to have helped – senshin Sep 29 '15 at 22:31
  • Weird, worth testing in the sandbox, maybe it's preserved only in preview. – Shadow The Curly Braced Wizard Sep 29 '15 at 22:33
  • 2
    I suspect this has nothing to do with making python consistent, but with browsers not rendering whitespace verbatim – Basic Sep 29 '15 at 22:33
  • 1
    <tab>s are also required in makefiles ... – DavidPostill Sep 29 '15 at 22:47
  • 1
    I ran into this issue while troubleshooting an issue with tab-delimited strings. – Steven M. Vascellaro Aug 10 '17 at 19:30

You must log in to answer this question.

Browse other questions tagged .