I’ve struggled to decide how to correctly capitalise species names on this blog, but finally made my decisions.

The pedant in me wants to say that English vernacular names for species are not capitalised, unless they contain a proper noun (Temminck’s Stint). However, I find that I unthinkingly introduce capitals when typing up my entries. This has led to a hodge-podge, which is far worse than being either correct or consistently incorrect.

My solution is to go with what comes naturally, which is to go with capitalised names. To address the hodge-podge, I wrote a quick Ruby script to fix up all of what I have already written.

  • it reads in my reference.yml file, which is an edited British List.
  • for each file in _posts it does a case-insensitive search for every species name, replacing instances with versions capitalised as per the British List.
  • all instances are changed, even those in the front-matter of each post. This doesn’t break anything, but it would have been more correct to work out how to restrict this to post bodies.
  • species names that are incorrect (abbreviated or wrongly-hyphenated) will have been left as-is.
  • I could expand this script to also convert matches to my synonyms.yml file (see this post for details) but that would break the aforementioned blog post and anyway I’m not running this script regularly. Better to regard this as a one-off and have done with it.
#!/usr/bin/env ruby

require 'yaml'
birds = YAML.load_file "_data/reference.yml"

# puts birds

Dir.foreach('_posts') do |item|
  next if item == '.' or item == '..' or item == '.DS_Store'
  text = File.read('_posts/' + item)
  birds.each do |bird|
    text.gsub!( /#{bird}/i, bird )
  end
  File.open('_posts/' + item, "w") {|file| file.puts text }
  puts item
end