Sometimes a code snipplet included in the original question is almost working, but not quite, and only requires a small fix. But sometimes it is important to show contextually where this fix goes (rather than just say "substitute X with Y"). As an example, in one of my recent answers the "fix" is only 11 additional characters out of more than 100. I think it will increase clarity if the differences are highlighted.

Is there a easy way to high light code differences?

I ask because in a "code" block, the bold and italics mark-ups are ignored.


Since Jukka forgot to include the source code for his answer, here it is:

Foo <b><i>bar</i></b> baz
Foo <s>baz</s> bah
  • I made it CW so that people can click "edit" to see it. :) Sep 3 '10 at 16:31
  • (... and it seems that I forgot that there is some kind of reputation threshold needed to edit CW posts. Apologies.) Sep 3 '10 at 16:32
  • @JukkaSuomela: And, as it turns out, it's actually possible to get to that post's revision history by clicking on your name or the date ... though I can't actually find a way to get to this post's history, for some reason. (They should really just add a "history" link next to "link" and "flag" ...)
    – SamB
    Feb 3 '12 at 5:56

You might use comments in your code like:

% Look! Here is what I changed!

I know that it doesn't sound like an elegant solution, but so far the SE engine doesn't include a diff tool :)



Foo bar baz
Foo baz bah

You must log in to answer this question.

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