Skip to content

Instantly share code, notes, and snippets.

@mfcabrera
Created August 29, 2012 08:46
Show Gist options
  • Save mfcabrera/3508701 to your computer and use it in GitHub Desktop.
Save mfcabrera/3508701 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bibtex'
b = BibTeX.open('./Sources_3_3_1.bib')
b.each { |citation|
if(citation.type != "comment" and ! citation.key.match(/^BR3/) )
citation.key = "BR3-#{citation.key}"
end
}
b.save_to("./Sources_3_3_1_fixed.bib")
match = "CommandInset citation"
endcmd = "\\end_inset"
flag = false;
File.open("3.3.1.lyx").each { |line|
flag = true if line.include?(match)
if(flag and line.include?("key \""))
flag = false;
key = line.scan(/"[^"]*"/)
neo_key = key[0].gsub("\"","")
puts "key \"BR3-#{neo_key}\""
else
puts line
end
flag = false if line.include? endcmd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment