Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

If you look at, for example, the revision history for this question on StackOverflow, the problem makes itself clear.

Specifically, look at the diff displayed for revision 5:

Now compare to the source for revision 4:

Notice that the diff for revision 5 displays (in red hilight) the string "\\'" (with only 2 backslashes) as the first argument to str_replace() in the old version, but the source for revision 4 reveals that it was actually "\\\'" (with 3 backslashes) all along.

share|improve this question

Nope, this is correct. In the Markdown of revision 4, there are indeed three backslashes at that spot, but the rendered version only has two. Look at the Markdown diff (third button from the top on the left side of the diff) of revision 5, and you'll see that the purpose of that revision was to enclose code in either backticks or code blocks.

Revision 4 had lots of code as plain text in it, and especially when it comes to backslashes, this makes a huge difference. Compare:

  1. The snippet from the example, as text:

    echo str_replace("\\'", "ba", "banana\'s");

  2. The snippet from the example, as code:

    echo str_replace("\\\'", "ba", "banana\'s");

Both of those have three backslashes in the first parameter; if you look at the source of this answer, you'll see that the only difference is indentation.

In non-code, a backslash can be used to escape characters that have special meaning in Markdown (example: \*stars, not italics\* -> *stars, not italics*). Thus the first two backslashes appear as only one in the rendered version, because the first escapes the second. The third appears on it's own, because it's followed by an apostrophe, which is not a special character in Markdown, and hence this backslash does not act as an escape.

In code, however, everything is literal: There are no escapes, and each backslash in the source creates a backslash in the final version.

Bottom line: In Revision 4, only two backslashes were visible in that particular spot in the rendered version, so the diff is absolutely correct.

share|improve this answer
Ah, true - good catch. Perhaps an option to allow setting which diff mode you view in by default would be useful? I'd personally prefer source diffs over render diffs, but that's definitely personal preference. – Amber Oct 13 '11 at 18:53
Cool thanks. :) – Amber Oct 14 '11 at 16:51

You must log in to answer this question.

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