36

The following answer contains an GNU Makefile:

https://stackoverflow.com/a/27190627/402322

I tried to use the Makefile on my system, but it does not work, because the syntax is broken.

I edited the answer and corrected the syntax. Indented lines need to be indented with exactly one tabulator and no spaces.

But after saving the change I realized, that the answer gets rendered in a way, which breaks the syntax of the file. The SO rendering replaces the tabulator with 4 spaces.

9
  • 4
    @ceving Check this please. The more recent versions of make don't require tabs strictly anymore. Jun 29, 2019 at 10:47
  • 25
    @πάνταῥεῖ Maybe. But it is no excuse for SO to break content. It is simply not okay to convert a tab into spaces. Think about Whitespace.
    – ceving
    Jun 29, 2019 at 21:18
  • @πάνταῥεῖ That question is about entering a TAB in the browser.
    – ceving
    Jun 29, 2019 at 21:30
  • Meta SE duplicate.
    – wizzwizz4
    Jun 30, 2019 at 17:11
  • 5
    Better title: SO Renderer Fights Back: Episode 3 -- Makefile Syntax
    – S.S. Anne
    Jun 30, 2019 at 22:35
  • 2
    Fixed in GNU Make 3.82, released in July 2010.
    – Cœur
    Jul 1, 2019 at 5:39
  • 1
    As @Cœur says the syntax is not broken, you simply have to specify RECIPEPREFIX as 4 spaces Jul 1, 2019 at 14:00
  • 9
    The problem is not that the changed (tab -> space replaced) makefile necessarily breaks. The problem is that on a website that is explicitly and exclusively about programming you can't enter ASCII code without worrying that the rendering engine will change the syntax. Just because modern systems also work with the changed version doesn't mean it's not broken. Jul 1, 2019 at 20:18

3 Answers 3

19

There's a workaround, as per mbomb007's answer to the Meta Stack Exchange feature request. Writing this:

<pre><code>Hello!
This is a tab:&#9;:bat a si sihT</code></pre>

makes:

Hello!
This is a tab:	:bat a si sihT

This, however, is by no means perfect, since you have to manually escape &, < and >. It is simply a hack.

7
  • I don't understand why this has so many downvotes. It's a perfectly valid solution.
    – S.S. Anne
    Jun 30, 2019 at 21:24
  • 5
    @JL2210 It's not a solution, though. It's a tricky, hackish workaround. The problem isn't solved by it.
    – wizzwizz4
    Jun 30, 2019 at 21:30
  • 3
    Well, Stack Exchange has made it clear that they're not going to support this (see status-declined on the Meta.SE duplicate that you posted), so... I guess this is the best tricky, hackish workaround we have.
    – S.S. Anne
    Jun 30, 2019 at 21:32
  • 3
    @JL2210 But it's a poor decision and woefully insufficient. I can come up with one reason every ten seconds for… some time, I think, that preserving tabs is a good idea.
    – wizzwizz4
    Jun 30, 2019 at 21:36
  • 3
    The workaround is to stop blindly copy/pasting code from the internet. Use your fingers and brain instead! Jul 1, 2019 at 13:47
  • 6
    @LightnessRacesinOrbit if you're gonna start expecting all programmers to understand the code they copy from the internet, global productivity is going to grind to a halt. Jul 1, 2019 at 16:35
  • 3
    @LightnessRacesinOrbit It takes both my fingers and my brain to copy and paste code from the internet.
    – Barry
    Jul 1, 2019 at 16:50
1

It is by design. In an answer to the MSE question that was mentioned earlier Shog9 provides reasons why it has been done this way (tl;dr; to make code in the snippets looks well for everyone).

As the one who used to use makefiles a lot I can understand your pain. On the other hand, I remember time when I was working with an old markdown editor (on another site) that did not change tabs into spaces. It was a huge disaster to format code to make it looks fine for everyone and we dreamed for such a feature.

1

As a workaround, you can use the special variable .RECIPEPREFIX to change the character used to indicate code from tabulator to something else that won't be scrambled by the renderer.

E.g.:

.RECIPEPREFIX = >

prog: foo.cc bar.cc baz.cc
> g++ $^ -o $@

You must log in to answer this question.

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