Ruby script to convert Hein Online citations to AGLC

I use Hein Online a lot, but have recently become sick of having to manually reformat the citations it gives me for journal articles (to the format I use, following the Australian Guide to Legal Citation. So, procrastinating, I wrote a quick script to do exactly that. Someone else may find it useful.

Input example:

82 Ind. L.J. 261 (2007)
On Virtual Worlds: Copyright and Contract Law at the Dawn of the Virtual Age; Reuveni, Erez

AGLC formatted output:
Reuveni, Erez , “On Virtual Worlds: Copyright and Contract Law at the Dawn of the Virtual Age” (2007) 82 Ind. L.J. 261

 

#!/usr/bin/ruby
# 20080603 Nic Suzor
# Available under CC BY-SA 2.5 (AU) http://creativecommons.org/licenses/by-sa/2.5/au/
#
# Alternatively, permission is granted to exercise any of the rights comprised
# in the copyright in this code, as long as the user agrees that it is provided with
# no warranty, express or implied, to the extent permissible by applicable law.

puts "this script will convert Hein Online citations to AGLC formatted citations."
puts "\n"
puts "enter a Hein Online cite (on up to two lines):"

cite = gets.chomp!
cite = cite + gets.chomp!

while cite != ''
#eg: 82 Ind. L.J. 261 (2007) On Virtual Worlds: Copyright and Contract Law at the Dawn of the Virtual Age; Reuveni, Erez
#becomes: Reuveni, Erez, "On Virtual Worlds: Copyright and Contract Law at the Dawn of the Virtual Age" (2007) 82 Ind. L.J. 261

cite = cite.gsub(/(.*?)(\(.*?\))(.*?); *(.*?)\Z/, '\4, "\3" \2 \1')

puts cite
puts "\nNext cite (enter two carriage returns to finish):\n"

cite = gets.chomp!
cite = cite + gets.chomp!

end

  1. No comments yet.

  1. No trackbacks yet.