Skip to content

Instantly share code, notes, and snippets.

@shirashin
Last active December 11, 2015 17:39
Show Gist options
  • Select an option

  • Save shirashin/4636177 to your computer and use it in GitHub Desktop.

Select an option

Save shirashin/4636177 to your computer and use it in GitHub Desktop.
del_color.rb <dir> del_color.rb <file>
# Remove color tag("\color{xxxx}") from the TeX File.
dir_path = ARGV[0]
if dir_path.nil? || dir_path.size == 0
print "ERROR: select target!!\n"
exit 255
end
print "target: #{dir_path}\n"
if File.file?(dir_path)
paths = [File.expand_path(dir_path)]
else
paths = Dir.glob(File.join(File.expand_path(dir_path), "*.tex"))
end
paths.each do |path|
str = nil
File.open(path, "r") do |f|
str = f.read
end
File.open(path, "wb") do |f|
print "override file: #{path}\n"
f.write str.gsub(/\\color\{.*?\}/, "")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment