Created
August 29, 2012 08:46
-
-
Save mfcabrera/3508701 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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