December 08, 2010
I just pushed a new version of my Diffy ruby gem.
This version does a better job when highlighting parts of lines in the html diff output.
Ward Cunningham pointed out to me that sometimes Diffy would get a little creative when finding similarities in between lines. For example, while technically correct Diffy 2.0.0 could come off as a bit of a know-it-all when it found one letter similarities between “Unescaped” and “Swallowed”.
- ==Links around Images==
- Images should link to absolute paths like ’/File:Picture.jpg’ instead of relative links (i.e. ‘File:Picture.jpg’).
- The later confuses my browser and causes it to link to file:///Picture.jpg, which won’t work at all.
==Unescaped html in nowiki tags==
- ==Swallowed html in nowiki tags==
The break tag in here is rendered.
- The break tag in here is not rendered as literal text despite being in nowiki and code tags. This differs from mediawiki’s behavior.
- “To create a line break put this <code><nowiki><br /></nowiki></code> in your markup.”
Version 2.0.1 suppresses this creativity a little bit for clearer output:
- ==Links around Images==
- Images should link to absolute paths like ’/File:Picture.jpg’ instead of relative links (i.e. ‘File:Picture.jpg’).
- The later confuses my browser and causes it to link to file:///Picture.jpg, which won’t work at all.
==Unescaped html in nowiki tags==
- ==Swallowed html in nowiki tags==
The break tag in here is rendered.
- The break tag in here is not rendered as literal text despite being in nowiki and code tags. This differs from mediawiki’s behavior.
- “To create a line break put this <code><nowiki><br /></nowiki></code> in your markup.”
Tagged with: diff |
November 26, 2010
I just released version 2.0 of Diffy.
I wanted to make it dead simple to generate attractive diff output from within a ruby application.
Here’s how you use it:
$ sudo gem install diffy
$ irb
>> string1 = <<-TXT
>" Hello how are you
>" I'm fine
>" That's great
>" TXT
=> "Hello how are you\nI'm fine\nThat's great\n"
>> string2 = <<-TXT
>" Hello how are you?
>" I'm fine
>" That's swell
>" TXT
=> "Hello how are you?\nI'm fine\nThat's swell\n"
>> puts Diffy::Diff.new(string1, string2)
-Hello how are you
+Hello how are you?
I'm fine
-That's great
+That's swell
It also will generate nice html for you:
>> Diffy::Diff.new(string1, string2).to_s(:html)
- We were all having a good time.
- Soon it was very late.
“Time flies like an arrow” said I.
- “Fruit flies like a banana” I said.
- Then I left.
You can find out more in the README
Tagged with: diff |
June 25, 2010
The other night at nopoconi I drank a couple Super Dog IPAs and hacked together a tiny web application that will run the content of any two web pages through a diffing tool. It’s up on wiff.me.
In the process I also discovered this crazy bash command that will pipe two web requests as inputs through diff using subshells. It’s kind of an insane one-liner.
diff <(curl 'drasticcode.com') <(curl 'www.drasticcode.com')
Needless to say I punted on trying to use the one-liner in the web based version. Echoing user provided data to the shell scares me. @donpdonp taught me how to sanitize the user provided data in the bash command. Just replace any single quotes in the user provided urls with two single quotes. I still ended up using Sinatra and Curb.
Tagged with: diff |