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

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: http://i.imgur.com/Oeqm4.png

Now compare to the source for revision 4: http://stackoverflow.com/revisions/916be6d4-2213-42b1-bf61-5277c82b1ca3/view-source

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

1 Answer 1

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
1  
    
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 .